Advertisement
Guest User

Untitled

a guest
May 28th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. video::SColor c;
  2. video::ITexture *texture = tsrc->getTexture(f->tiledef[0].name);
  3. if (texture) {
  4. video::IImage *image1 = driver->createImage(texture,
  5. core::position2d<s32>(0, 0),
  6. texture->getOriginalSize());
  7.  
  8. u32 total = 0;
  9. u32 tR = 0;
  10. u32 tG = 0;
  11. u32 tB = 0;
  12. core::dimension2d<u32> dim = image1->getDimension();
  13. for (s16 dy = 0; dy < dim.Height; dy++) {
  14. for (s16 dx = 0; dx < dim.Width; dx++) {
  15. video::SColor c = image1->getPixel(dx,dy);
  16. if (c.getAlpha() > 0) {
  17. total++;
  18. tR+=c.getRed();
  19. tG+=c.getGreen();
  20. tB+=c.getBlue();
  21. }
  22. }
  23. }
  24. if (total > 0) {
  25. c.setRed(tR / total);
  26. c.setGreen(tG / total);
  27. c.setBlue(tB / total);
  28. }
  29. c.setAlpha(240);
  30. f->minimap_color = c;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement