Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- video::SColor c;
- video::ITexture *texture = tsrc->getTexture(f->tiledef[0].name);
- if (texture) {
- video::IImage *image1 = driver->createImage(texture,
- core::position2d<s32>(0, 0),
- texture->getOriginalSize());
- u32 total = 0;
- u32 tR = 0;
- u32 tG = 0;
- u32 tB = 0;
- core::dimension2d<u32> dim = image1->getDimension();
- for (s16 dy = 0; dy < dim.Height; dy++) {
- for (s16 dx = 0; dx < dim.Width; dx++) {
- video::SColor c = image1->getPixel(dx,dy);
- if (c.getAlpha() > 0) {
- total++;
- tR+=c.getRed();
- tG+=c.getGreen();
- tB+=c.getBlue();
- }
- }
- }
- if (total > 0) {
- c.setRed(tR / total);
- c.setGreen(tG / total);
- c.setBlue(tB / total);
- }
- c.setAlpha(240);
- f->minimap_color = c;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement