summaryrefslogtreecommitdiff
path: root/glcdskin/object.c
diff options
context:
space:
mode:
authormrwastl <mrwastl@users.sourceforge.net>2011-10-15 18:41:49 +0200
committermrwastl <mrwastl@users.sourceforge.net>2011-10-15 18:41:49 +0200
commitcb4534730274a32e7c4e64c7f282bd258375b1f9 (patch)
treee14bfcce71b13d802a31cdae9ed7b43cff9dc1b1 /glcdskin/object.c
parentab3acde2326a9d8f942995325b71b3aeaf24b918 (diff)
downloadgraphlcd-base-cb4534730274a32e7c4e64c7f282bd258375b1f9.tar.gz
graphlcd-base-cb4534730274a32e7c4e64c7f282bd258375b1f9.tar.bz2
support for scaling of images (image/graphicsmagick supported images only at the moment); skins: additional paraemter 'scale' for <image/>; added method for emptying of image cache (cImageCache::Clear())
Diffstat (limited to 'glcdskin/object.c')
-rw-r--r--glcdskin/object.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/glcdskin/object.c b/glcdskin/object.c
index b2dffe7..7c6b75d 100644
--- a/glcdskin/object.c
+++ b/glcdskin/object.c
@@ -64,6 +64,7 @@ cSkinObject::cSkinObject(cSkinDisplay * Parent)
mStoredImagePath(""),
mImageFrameId(0), // start with 1st frame
mOpacity(255), // default: full opacity
+ mScale(tscNone), // scale image: default: don't scale
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)
@@ -117,6 +118,7 @@ cSkinObject::cSkinObject(const cSkinObject & Src)
mStoredImagePath(Src.mStoredImagePath),
mImageFrameId(0),
mOpacity(Src.mOpacity),
+ mScale(Src.mScale),
mScrollLoopMode(Src.mScrollLoopMode),
mScrollLoopReached(Src.mScrollLoopReached),
mScrollSpeed(Src.mScrollSpeed),
@@ -227,6 +229,21 @@ bool cSkinObject::ParseEffect(const std::string & Text)
return true;
}
+bool cSkinObject::ParseScale(const std::string & Text)
+{
+ if (Text == "none")
+ mScale = tscNone;
+ else if (Text == "autox")
+ mScale = tscAutoX;
+ else if (Text == "autoy")
+ mScale = tscAutoY;
+ else if (Text == "fill")
+ mScale = tscFill;
+ else
+ return false;
+ return true;
+}
+
bool cSkinObject::ParseIntParam(const std::string &Text, int & Param)
{
if (isalpha(Text[0]) || Text[0] == '#')
@@ -413,7 +430,26 @@ void cSkinObject::Render(GLCD::cBitmap * screen)
mChangeDelay = -1;
}
- GLCD::cImage * image = cache->Get(evalPath);
+ uint16_t scalew = 0;
+ uint16_t scaleh = 0;
+
+ switch (mScale) {
+ case tscAutoX:
+ scalew = Size().w;
+ break;
+ case tscAutoY:
+ scaleh = Size().h;
+ break;
+ case tscFill:
+ scalew = Size().w;
+ scaleh = Size().h;
+ break;
+ default:
+ scalew = 0;
+ scaleh = 0;
+ }
+
+ GLCD::cImage * image = cache->Get(evalPath, scalew, scaleh);
if (image)
{
int framecount = image->Count();