diff options
author | mrwastl <mrwastl@users.sourceforge.net> | 2012-09-23 22:42:23 +0200 |
---|---|---|
committer | mrwastl <mrwastl@users.sourceforge.net> | 2012-09-23 22:42:23 +0200 |
commit | 6bbc07ed1dc8f617222f229df083c8cca60d1608 (patch) | |
tree | ae882287892765d3e3431482dbe93fb1bd3c9bde | |
parent | a6d4ea3c068b909ca80a0ff8d7ed4db208c011b1 (diff) | |
download | graphlcd-base-6bbc07ed1dc8f617222f229df083c8cca60d1608.tar.gz graphlcd-base-6bbc07ed1dc8f617222f229df083c8cca60d1608.tar.bz2 |
extformats.c: use scaleQuantumToDouble() to get colour values in range 0 to 255; avoid MaxRGB/QuantumRange at all
-rw-r--r-- | glcdgraphics/extformats.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/glcdgraphics/extformats.c b/glcdgraphics/extformats.c index afc47d6..3a0ab36 100644 --- a/glcdgraphics/extformats.c +++ b/glcdgraphics/extformats.c @@ -28,8 +28,6 @@ //#include <Imlib2.h> #endif -#include <math.h> - namespace GLCD { @@ -131,17 +129,20 @@ bool cExtFormatFile::LoadScaled(cImage & image, const string & fileName, uint16_ //Dprintf("this image has %d colors\n", (*it).totalColors()); bool isMatte = (*it).matte(); - size_t qrange = (size_t)pow(2.0, (*it).depth()) - 1; //bool isMonochrome = ((*it).totalColors() <= 2) ? true : false; const Magick::PixelPacket *pix = (*it).getConstPixels(0, 0, (int)width, (int)height); for (int iy = 0; iy < (int)height; ++iy) { for (int ix = 0; ix < (int)width; ++ix) { - if ( isMatte && pix->opacity == qrange ) { + if ( isMatte && Magick::Color::scaleQuantumToDouble(pix->opacity) * 255 == 255 ) { bmpdata[iy*width+ix] = cColor::Transparent; } else { - //bmpdata[iy*width+ix] = (uint32_t)( 0xFF000000 | (int(pix->red * 255 / MaxRGB) << 16) | (int(pix->green * 255 / MaxRGB) << 8) | int(pix->blue * 255 / MaxRGB)); - bmpdata[iy*width+ix] = (uint32_t)( (int(255 - (pix->opacity * 255 / qrange)) << 24) | (int(pix->red * 255 / qrange) << 16) | (int(pix->green * 255 / qrange) << 8) | int(pix->blue * 255 / qrange)); + bmpdata[iy*width+ix] = (uint32_t)( + (uint32_t(255 - (Magick::Color::scaleQuantumToDouble(pix->opacity) * 255)) << 24) | + (uint32_t( Magick::Color::scaleQuantumToDouble(pix->red) * 255) << 16) | + (uint32_t( Magick::Color::scaleQuantumToDouble(pix->green) * 255) << 8) | + uint32_t( Magick::Color::scaleQuantumToDouble(pix->blue) * 255) + ); //if ( isMonochrome ) { // if is monochrome: exchange black and white // uint32_t c = bmpdata[iy*width+ix]; // switch(c) { |