restore outfit colors

* rework sprite manager and ThingType
* render colored outfits again compatible with OpenGL 1
This commit is contained in:
Eduardo Bart
2012-05-09 17:26:34 -03:00
parent fea34a41ea
commit 6495d74edd
19 changed files with 193 additions and 268 deletions

View File

@@ -31,7 +31,8 @@ Image::Image(const Size& size, int bpp, uint8 *pixels)
m_size = size;
m_bpp = bpp;
m_pixels.resize(size.area() * bpp);
memcpy(&m_pixels[0], pixels, m_pixels.size());
if(pixels)
memcpy(&m_pixels[0], pixels, m_pixels.size());
}
ImagePtr Image::load(const std::string& file)
@@ -62,3 +63,23 @@ ImagePtr Image::loadPNG(const std::string& file)
}
return image;
}
void Image::overwriteMask(const Color& maskedColor, const Color& insideColor, const Color& outsideColor)
{
assert(m_bpp == 4);
for(int p=0;p<getPixelCount();p++) {
uint8& r = m_pixels[p*4 + 0];
uint8& g = m_pixels[p*4 + 1];
uint8& b = m_pixels[p*4 + 2];
uint8& a = m_pixels[p*4 + 3];
Color pixelColor(r,g,b,a);
Color writeColor = (pixelColor == maskedColor) ? insideColor : outsideColor;
r = writeColor.r();
g = writeColor.g();
b = writeColor.b();
a = writeColor.a();
}
}