diff options
author | mrwastl <mrwastl@users.sourceforge.net> | 2012-09-22 18:51:28 +0200 |
---|---|---|
committer | mrwastl <mrwastl@users.sourceforge.net> | 2012-09-22 18:51:28 +0200 |
commit | a6d4ea3c068b909ca80a0ff8d7ed4db208c011b1 (patch) | |
tree | 3fe8ca87859923320297921e8c0359133f21e980 /glcdgraphics/extformats.c | |
parent | bfcdb24a0e7f4cbcc439c31fd141e3ea90da0734 (diff) | |
download | graphlcd-base-a6d4ea3c068b909ca80a0ff8d7ed4db208c011b1.tar.gz graphlcd-base-a6d4ea3c068b909ca80a0ff8d7ed4db208c011b1.tar.bz2 |
extformats.c: Image/GraphicsMagick: avoid usage of MaxRGB and QuantumRange
Diffstat (limited to 'glcdgraphics/extformats.c')
-rw-r--r-- | glcdgraphics/extformats.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/glcdgraphics/extformats.c b/glcdgraphics/extformats.c index f0bfc7f..afc47d6 100644 --- a/glcdgraphics/extformats.c +++ b/glcdgraphics/extformats.c @@ -28,6 +28,8 @@ //#include <Imlib2.h> #endif +#include <math.h> + namespace GLCD { @@ -129,16 +131,17 @@ 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 == MaxRGB ) { + if ( isMatte && pix->opacity == qrange ) { 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 / MaxRGB)) << 24) | (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)); //if ( isMonochrome ) { // if is monochrome: exchange black and white // uint32_t c = bmpdata[iy*width+ix]; // switch(c) { |