diff options
author | mrwastl <mrwastl@users.sourceforge.net> | 2011-05-24 21:21:52 +0200 |
---|---|---|
committer | mrwastl <mrwastl@users.sourceforge.net> | 2011-05-24 21:21:52 +0200 |
commit | 84efb00f6b7b30ddbfd0551aae3130e86c90562c (patch) | |
tree | 489c4e9e4ff9ae8466caf522cfdaef58efda019b /glcdgraphics/extformats.c | |
parent | 38bea28bf1f88a45f2ada8b7f1c95cd5ea89a6bc (diff) | |
download | graphlcd-base-84efb00f6b7b30ddbfd0551aae3130e86c90562c.tar.gz graphlcd-base-84efb00f6b7b30ddbfd0551aae3130e86c90562c.tar.bz2 |
support for transparency (images and text); text and images are transparent per default; bug fix: crash when allocing bitmap object with width=0
Diffstat (limited to 'glcdgraphics/extformats.c')
-rw-r--r-- | glcdgraphics/extformats.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/glcdgraphics/extformats.c b/glcdgraphics/extformats.c index 0d39880..6a8de20 100644 --- a/glcdgraphics/extformats.c +++ b/glcdgraphics/extformats.c @@ -75,8 +75,8 @@ bool cExtFormatFile::Load(cImage & image, const string & fileName) bool ignoreImage = false; //if (colors != 0){ - (*it).opacity(OpaqueOpacity); - (*it).backgroundColor( Color ( 0,0,0,0) ); + //(*it).opacity(OpaqueOpacity); + //(*it).backgroundColor( Color ( 0,0,0,0) ); (*it).quantizeColorSpace( RGBColorspace ); (*it).quantizeColors( 256*256*256 /*colors*/ ); (*it).quantize(); @@ -107,7 +107,11 @@ bool cExtFormatFile::Load(cImage & image, const string & fileName) const 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) { - bmpdata[iy*width+ix] = (uint32_t)((~int(pix->opacity * 255 / MaxRGB) << 24) | (int(pix->red * 255 / MaxRGB) << 16) | (int(pix->green * 255 / MaxRGB) << 8) | int(pix->blue * 255 / MaxRGB)); + if ( (int(pix->opacity * 255 / MaxRGB)) < 225 ) { // just an arbitrary border ... + bmpdata[iy*width+ix] = (uint32_t)((~int(pix->opacity * 255 / MaxRGB) << 24) | (int(pix->red * 255 / MaxRGB) << 16) | (int(pix->green * 255 / MaxRGB) << 8) | int(pix->blue * 255 / MaxRGB)); + } else { + bmpdata[iy*width+ix] = cColor::Transparent; + } ++pix; } } |