diff options
Diffstat (limited to 'glcdgraphics')
-rw-r--r-- | glcdgraphics/bitmap.c | 6 | ||||
-rw-r--r-- | glcdgraphics/bitmap.h | 4 | ||||
-rw-r--r-- | glcdgraphics/extformats.c | 19 | ||||
-rw-r--r-- | glcdgraphics/extformats.h | 2 | ||||
-rw-r--r-- | glcdgraphics/imagefile.c | 12 | ||||
-rw-r--r-- | glcdgraphics/imagefile.h | 3 |
6 files changed, 27 insertions, 19 deletions
diff --git a/glcdgraphics/bitmap.c b/glcdgraphics/bitmap.c index b96fe6d..d6f0d11 100644 --- a/glcdgraphics/bitmap.c +++ b/glcdgraphics/bitmap.c @@ -10,7 +10,7 @@ * to the COPYING file distributed with this package. * * (c) 2004-2010 Andreas Regel <andreas.regel AT powarman.de> - * (c) 2010-2011 Wolfgang Astleitner <mrwastl AT users sourceforge net> + * (c) 2010-2012 Wolfgang Astleitner <mrwastl AT users sourceforge net> * Andreas 'randy' Weinberger */ @@ -570,7 +570,7 @@ void cBitmap::DrawBitmap(int x, int y, const cBitmap & bitmap, uint32_t color, u uint32_t cl = 0; const uint32_t * data = bitmap.Data(); - bool ismonochrome = bitmap.IsMonochrome(); + bool ismono = bitmap.IsMonochrome(); int xt, yt; uint32_t alpha; @@ -583,7 +583,7 @@ void cBitmap::DrawBitmap(int x, int y, const cBitmap & bitmap, uint32_t color, u { cl = data[(yt * bitmap.Width())+xt]; if (cl != cColor::Transparent) { - if (ismonochrome) { + if (ismono) { cl = (cl == cColor::Black) ? color : bgcolor; } if (opacity != 255) { diff --git a/glcdgraphics/bitmap.h b/glcdgraphics/bitmap.h index 5710a78..2c4a2af 100644 --- a/glcdgraphics/bitmap.h +++ b/glcdgraphics/bitmap.h @@ -10,7 +10,7 @@ * to the COPYING file distributed with this package. * * (c) 2004-2010 Andreas Regel <andreas.regel AT powarman.de> - * (c) 2010-2011 Wolfgang Astleitner <mrwastl AT users sourceforge net> + * (c) 2010-2012 Wolfgang Astleitner <mrwastl AT users sourceforge net> * Andreas 'randy' Weinberger */ @@ -127,7 +127,7 @@ public: cBitmap * SubBitmap(int x1, int y1, int x2, int y2) const; uint32_t GetPixel(int x, int y) const; - void SetMonochrome(bool mono) { ismonochrome = mono; } + void SetMonochrome(bool ismono) { ismonochrome = ismono; } bool IsMonochrome(void) const { return ismonochrome; } void SetProcessAlpha(bool procAlpha) { processAlpha = procAlpha; } diff --git a/glcdgraphics/extformats.c b/glcdgraphics/extformats.c index 764f85c..f0bfc7f 100644 --- a/glcdgraphics/extformats.c +++ b/glcdgraphics/extformats.c @@ -8,7 +8,7 @@ * This file is released under the GNU General Public License. Refer * to the COPYING file distributed with this package. * - * (c) 2011 Wolfgang Astleitner <mrwastl AT users sourceforge net> + * (c) 2011-2012 Wolfgang Astleitner <mrwastl AT users sourceforge net> */ #include <stdio.h> @@ -23,7 +23,6 @@ #ifdef HAVE_IMAGEMAGICK #include <Magick++.h> -using namespace Magick; //#elif defined(HAVE_IMLIB2) //#include "quantize.h" //#include <Imlib2.h> @@ -39,7 +38,7 @@ using namespace std; cExtFormatFile::cExtFormatFile() { #ifdef HAVE_IMAGEMAGICK - InitializeMagick(NULL); + Magick::InitializeMagick(NULL); #endif } @@ -57,14 +56,14 @@ bool cExtFormatFile::Load(cImage & image, const string & fileName) bool cExtFormatFile::LoadScaled(cImage & image, const string & fileName, uint16_t & scalew, uint16_t & scaleh) { #ifdef HAVE_IMAGEMAGICK - std::vector<Image> extimages; + std::vector<Magick::Image> extimages; try { uint16_t width = 0; uint16_t height = 0; //uint16_t count; uint32_t delay; - std::vector<Image>::iterator it; + std::vector<Magick::Image>::iterator it; readImages(&extimages, fileName); if (extimages.size() == 0) { syslog(LOG_ERR, "ERROR: graphlcd: Couldn't load %s", fileName.c_str()); @@ -81,7 +80,7 @@ bool cExtFormatFile::LoadScaled(cImage & image, const string & fileName, uint16_ for (it = extimages.begin(); it != extimages.end(); ++it) { bool ignoreImage = false; - //(*it).quantizeColorSpace( RGBColorspace ); + //(*it).quantizeColorSpace( Magick::RGBColorspace ); //(*it).quantizeColors( 256*256*256 /*colors*/ ); //(*it).quantize(); @@ -99,7 +98,7 @@ bool cExtFormatFile::LoadScaled(cImage & image, const string & fileName, uint16_ // scale image if (scalew && ! (scalew == width && scaleh == height)) { - (*it).scale(Geometry(scalew, scaleh)); + (*it).sample(Magick::Geometry(scalew, scaleh)); width = scalew; height = scaleh; } else { @@ -112,7 +111,7 @@ bool cExtFormatFile::LoadScaled(cImage & image, const string & fileName, uint16_ image.SetHeight(height); } else { if (scalew && scaleh) { - (*it).scale(Geometry(scalew, scaleh)); + (*it).sample(Magick::Geometry(scalew, scaleh)); } else if ( (width != (uint16_t)((*it).columns())) || (height != (uint16_t)((*it).rows())) ) { ignoreImage = true; @@ -131,7 +130,7 @@ bool cExtFormatFile::LoadScaled(cImage & image, const string & fileName, uint16_ bool isMatte = (*it).matte(); //bool isMonochrome = ((*it).totalColors() <= 2) ? true : false; - const PixelPacket *pix = (*it).getConstPixels(0, 0, (int)width, (int)height); + 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) { @@ -159,7 +158,7 @@ bool cExtFormatFile::LoadScaled(cImage & image, const string & fileName, uint16_ bmpdata = NULL; } } - } catch (Exception &e) { + } catch (Magick::Exception &e) { syslog(LOG_ERR, "ERROR: graphlcd: Couldn't load %s: %s", fileName.c_str(), e.what()); return false; } catch (...) { diff --git a/glcdgraphics/extformats.h b/glcdgraphics/extformats.h index b910c3c..23f6ea2 100644 --- a/glcdgraphics/extformats.h +++ b/glcdgraphics/extformats.h @@ -8,7 +8,7 @@ * This file is released under the GNU General Public License. Refer * to the COPYING file distributed with this package. * - * (c) 2011 Wolfgang Astleitner <mrwastl AT users sourceforge net> + * (c) 2011-2012 Wolfgang Astleitner <mrwastl AT users sourceforge net> */ #ifndef _GLCDGRAPHICS_EXTFORMATS_H_ diff --git a/glcdgraphics/imagefile.c b/glcdgraphics/imagefile.c index d6baf24..b8c6a42 100644 --- a/glcdgraphics/imagefile.c +++ b/glcdgraphics/imagefile.c @@ -6,7 +6,8 @@ * This file is released under the GNU General Public License. Refer * to the COPYING file distributed with this package. * - * (c) 2006 Andreas Regel <andreas.regel AT powarman.de> + * (c) 2006 Andreas Regel <andreas.regel AT powarman.de> + * (c) 2010-2012 Wolfgang Astleitner <mrwastl AT users sourceforge net> */ #include "image.h" @@ -96,6 +97,8 @@ bool cImageFile::Scale(cImage & image, uint16_t scalew, uint16_t scaleh, bool An cBitmap *b = new cBitmap(scalew, scaleh, GRAPHLCD_Transparent); cBitmap *currFrame = image.GetBitmap(frame); + + b->SetMonochrome(currFrame->IsMonochrome()); if (downscale) { // Downscaling - no anti-aliasing: @@ -140,8 +143,13 @@ bool cImageFile::Scale(cImage & image, uint16_t scalew, uint16_t scaleh, bool An image.SetWidth(scalew); image.SetHeight(scaleh); // re-add bitmaps from scaled image container + cBitmap * b; + cBitmap * tempb; for (unsigned int frame = 0; frame < tempImg.Count(); frame ++) { - image.AddBitmap(new cBitmap(scalew, scaleh, (uint32_t*)tempImg.GetBitmap(frame)->Data())); + tempb = tempImg.GetBitmap(frame); + b = new cBitmap(scalew, scaleh, (uint32_t*)tempb->Data()); + b->SetMonochrome(tempb->IsMonochrome()); + image.AddBitmap(b); } return true; } diff --git a/glcdgraphics/imagefile.h b/glcdgraphics/imagefile.h index 959d31e..60049ea 100644 --- a/glcdgraphics/imagefile.h +++ b/glcdgraphics/imagefile.h @@ -6,7 +6,8 @@ * This file is released under the GNU General Public License. Refer * to the COPYING file distributed with this package. * - * (c) 2006 Andreas Regel <andreas.regel AT powarman.de> + * (c) 2006 Andreas Regel <andreas.regel AT powarman.de> + * (c) 2010-2012 Wolfgang Astleitner <mrwastl AT users sourceforge net> */ #ifndef _GLCDGRAPHICS_IMAGEFILE_H_ |