diff options
author | mrwastl <mrwastl@users.sourceforge.net> | 2011-06-20 23:13:54 +0200 |
---|---|---|
committer | mrwastl <mrwastl@users.sourceforge.net> | 2011-06-20 23:13:54 +0200 |
commit | 8b198b4be836b4718cd3ce96e8ba8590697da45a (patch) | |
tree | 7645b90529daaf97a4eaa4ecdedeb93fff4056af /glcdskin | |
parent | ec46b70bd4d1a1450a2bdc197d9e5935c885c40c (diff) | |
download | graphlcd-base-8b198b4be836b4718cd3ce96e8ba8590697da45a.tar.gz graphlcd-base-8b198b4be836b4718cd3ce96e8ba8590697da45a.tar.bz2 |
opacity support for non-monochrome images
Diffstat (limited to 'glcdskin')
-rw-r--r-- | glcdskin/object.c | 4 | ||||
-rw-r--r-- | glcdskin/object.h | 1 | ||||
-rw-r--r-- | glcdskin/parser.c | 7 |
3 files changed, 11 insertions, 1 deletions
diff --git a/glcdskin/object.c b/glcdskin/object.c index 336f21e..107e8f5 100644 --- a/glcdskin/object.c +++ b/glcdskin/object.c @@ -55,6 +55,7 @@ cSkinObject::cSkinObject(cSkinDisplay * Parent) mChangeDelay(-1), // delay between two images frames: -1: not animated / don't care mStoredImagePath(""), mImageFrameId(0), // start with 1st frame + mOpacity(255), // default: full opacity mScrollLoopMode(-1), // scroll (text) or loop (image) mode: default (-1) mScrollLoopReached(false), // if scroll/loop == once: already looped once? mScrollSpeed(0), // scroll speed: default (0) @@ -97,6 +98,7 @@ cSkinObject::cSkinObject(const cSkinObject & Src) mChangeDelay(-1), mStoredImagePath(Src.mStoredImagePath), mImageFrameId(0), + mOpacity(Src.mOpacity), mScrollLoopMode(Src.mScrollLoopMode), mScrollLoopReached(Src.mScrollLoopReached), mScrollSpeed(Src.mScrollSpeed), @@ -384,7 +386,7 @@ void cSkinObject::Render(GLCD::cBitmap * screen) if (mColor == cColor::ERRCOL) screen->DrawBitmap(Pos().x, Pos().y, *bitmap); else - screen->DrawBitmap(Pos().x, Pos().y, *bitmap, mColor, mBackgroundColor); + screen->DrawBitmap(Pos().x, Pos().y, *bitmap, mColor, mBackgroundColor, mOpacity); } if (mScrollLoopMode != -1) // if == -1: currScrollLoopMode already contains correct value diff --git a/glcdskin/object.h b/glcdskin/object.h index 5131cd4..e48b46f 100644 --- a/glcdskin/object.h +++ b/glcdskin/object.h @@ -148,6 +148,7 @@ private: std::string mStoredImagePath; // stored image path int mImageFrameId; // frame ID of image + int mOpacity; // opacity of an image ([0, 255], default 255) int mScrollLoopMode; // scroll (text) or loop (image) mode: -1: default, 0: never, 1: once, 2: always bool mScrollLoopReached; // if scroll/loop == once: already looped once? diff --git a/glcdskin/parser.c b/glcdskin/parser.c index b017326..71df8e1 100644 --- a/glcdskin/parser.c +++ b/glcdskin/parser.c @@ -281,6 +281,7 @@ bool StartElem(const std::string & name, std::map<std::string,std::string> & att ATTRIB_OPT_FUNC_PARAM("bgcolor", object->ParseColor, object->mBackgroundColor); ATTRIB_MAN_FUNC("path", object->mPath.Parse); ATTRIB_OPT_FUNC("loop", object->ParseScrollLoopMode); + ATTRIB_OPT_FUNC_PARAM("opacity", object->ParseIntParam, object->mOpacity); } else if (name == "text" || name == "scrolltext") @@ -341,6 +342,12 @@ bool StartElem(const std::string & name, std::map<std::string,std::string> & att --object->mPos2.y; } #endif + // range checks + if (object->mOpacity < 0) + object->mOpacity = 0; + else if (object->mOpacity > 255) + object->mOpacity = 255; + } else TAG_ERR_REMAIN(context[context.size() - 1].c_str()); |