diff options
author | mrwastl <mrwastl@users.sourceforge.net> | 2012-09-22 15:56:17 +0200 |
---|---|---|
committer | mrwastl <mrwastl@users.sourceforge.net> | 2012-09-22 15:56:17 +0200 |
commit | 47dbc367354f6d8c97b8b54c78fb489d2438c6a0 (patch) | |
tree | a7bc42257f972ccdc1e105397a56f5ae6d9bb134 | |
parent | da8cde9d90dff5b93fd130880987eaa755e3497a (diff) | |
download | graphlcd-base-47dbc367354f6d8c97b8b54c78fb489d2438c6a0.tar.gz graphlcd-base-47dbc367354f6d8c97b8b54c78fb489d2438c6a0.tar.bz2 |
extformats: replace deprecated MaxRGB through QuantumRange (ImageMagick) and add a define for GraphicsMagick to accept QuantumRange
-rw-r--r-- | glcdgraphics/extformats.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/glcdgraphics/extformats.c b/glcdgraphics/extformats.c index f0bfc7f..4b3978d 100644 --- a/glcdgraphics/extformats.c +++ b/glcdgraphics/extformats.c @@ -26,6 +26,10 @@ //#elif defined(HAVE_IMLIB2) //#include "quantize.h" //#include <Imlib2.h> + /* ImageMagick threw away deprecated MaxRGB in a recent version (~ 6.7.0) but GraphicsMagick still doesn't have QuantumRange (1.3.x) */ + #ifndef QuantumRange + #define QuantumRange MaxRGB + #endif #endif @@ -134,11 +138,11 @@ bool cExtFormatFile::LoadScaled(cImage & image, const string & fileName, uint16_ 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 == QuantumRange ) { 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 / QuantumRange)) << 24) | (int(pix->red * 255 / QuantumRange) << 16) | (int(pix->green * 255 / QuantumRange) << 8) | int(pix->blue * 255 / QuantumRange)); //if ( isMonochrome ) { // if is monochrome: exchange black and white // uint32_t c = bmpdata[iy*width+ix]; // switch(c) { |