From 84efb00f6b7b30ddbfd0551aae3130e86c90562c Mon Sep 17 00:00:00 2001 From: mrwastl Date: Tue, 24 May 2011 21:21:52 +0200 Subject: support for transparency (images and text); text and images are transparent per default; bug fix: crash when allocing bitmap object with width=0 --- glcdgraphics/extformats.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'glcdgraphics/extformats.c') 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; } } -- cgit v1.2.3