diff options
author | Manuel Reimer <manuel.reimer@gmx.de> | 2013-11-12 17:03:11 +0100 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2013-11-12 17:03:11 +0100 |
commit | 735f22370b0d48c8c121a31c115e9d72af895eca (patch) | |
tree | f947bcec75ebf52ce78ec59071944a2a2ed55f0f | |
parent | 09a6323046f959a748a6a15fc2aa1e1af1ffba7c (diff) | |
download | skin-nopacity-735f22370b0d48c8c121a31c115e9d72af895eca.tar.gz skin-nopacity-735f22370b0d48c8c121a31c115e9d72af895eca.tar.bz2 |
implemented GraphicsMagick compatibility
-rw-r--r-- | HISTORY | 4 | ||||
-rw-r--r-- | Makefile | 13 | ||||
-rw-r--r-- | imagecache.c | 16 | ||||
-rw-r--r-- | imagemagickwrapper.c | 45 | ||||
-rw-r--r-- | imagemagickwrapper.h | 2 |
5 files changed, 50 insertions, 30 deletions
@@ -363,3 +363,7 @@ Version 0.1.4 - Added theme dependend background for status icon in displayreplay - Fixed editing of text if text is scrolling (closes Bug 1572) - Cutting too long recording name in displayreplay +- implemented GraphicsMagick compatibility (thanks @Manuel Reimer + for providing the patch) +- changed Makefile to support both ImageMagick and GraphicsMagick + (configurable in Makefile) @@ -3,6 +3,9 @@ # # $Id$ +# External image lib to use: imagemagick, graphicsmagick +IMAGELIB = imagemagick + # The official name of this plugin. # This name will be used in the '-P...' option of VDR to load the plugin. # By default the main source file also carries this name. @@ -48,11 +51,15 @@ SOFILE = libvdr-$(PLUGIN).so ### Includes and Defines and Dependencies (add further entries here): -INCLUDES += $(shell pkg-config --cflags Magick++) - DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -LIBS += $(shell pkg-config --libs Magick++) +ifeq ($(IMAGELIB), imagemagick) + INCLUDES += $(shell pkg-config --cflags Magick++) + LIBS += $(shell pkg-config --libs Magick++) +else ifeq ($(IMAGELIB), graphicsmagick) + INCLUDES += $(shell pkg-config --cflags GraphicsMagick++) + LIBS += $(shell pkg-config --libs GraphicsMagick++) +endif ### The object files (add further files here): diff --git a/imagecache.c b/imagecache.c index 5b6cbcf..9fb1690 100644 --- a/imagecache.c +++ b/imagecache.c @@ -324,12 +324,9 @@ bool cImageCache::LoadIcon(eCacheType type, std::string name) { } void cImageCache::InsertIntoIconCache(eCacheType type, std::string name, int width, int height, bool preserveAspect) { - if (preserveAspect) { - buffer.sample(Geometry(width, height)); - } else { - cString geometry = cString::sprintf("%dx%d!", width, height); - buffer.resize(Geometry(*geometry)); - } + Geometry size(width, height); + size.aspect(!preserveAspect); + buffer.sample(size); cImage *image = CreateImage(); if (type == ctMenuIcon) menuIconCache.insert(std::pair<std::string, cImage*>(name, image)); @@ -692,8 +689,9 @@ void cImageCache::CreateSkinElementsGraphics(void) { void cImageCache::InsertIntoSkinElementCache(eSkinElementType type, int width, int height) { if (width>0 && height>0) { - cString geometry = cString::sprintf("%dx%d!", width, height); - buffer.resize(Geometry(*geometry)); + Geometry size(width, height); + size.aspect(true); + buffer.sample(size); } cImage *image = CreateImage(); skinElementCache.insert(std::pair<eSkinElementType, cImage*>(type, image)); @@ -735,4 +733,4 @@ void cImageCache::Clear(void) { delete img; } logoTimerCache.clear(); -}
\ No newline at end of file +} diff --git a/imagemagickwrapper.c b/imagemagickwrapper.c index c22faf4..7cdf980 100644 --- a/imagemagickwrapper.c +++ b/imagemagickwrapper.c @@ -88,27 +88,36 @@ Color cImageMagickWrapper::Argb2Color(tColor col) { return color; } -void cImageMagickWrapper::CreateBackground(tColor back, tColor blend, int width, int height, bool mirror) { +void cImageMagickWrapper::CreateGradient(tColor back, tColor blend, int width, int height, double wfactor, double hfactor) { Color Back = Argb2Color(back); Color Blend = Argb2Color(blend); - Image tmp(Geometry(width, height), Blend); - double arguments[9] = {0.0,(double)height,0.0,-1*(double)width,0.0,0.0,1.5*(double)width,0.0,1.0}; - tmp.sparseColor(MatteChannel, BarycentricColorInterpolate, 9, arguments); - Image tmp2(Geometry(width, height), Back); - tmp.composite(tmp2, 0, 0, OverlayCompositeOp); - if (mirror) - tmp.flop(); - buffer = tmp; + int maxw = MaxRGB * wfactor; + int maxh = MaxRGB * hfactor; + + Image imgblend(Geometry(width, height), Blend); + imgblend.modifyImage(); + imgblend.type(TrueColorMatteType); + PixelPacket *pixels = imgblend.getPixels(0, 0, width, height); + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + PixelPacket *pixel = pixels + y * width + x; + int opacity = (maxw / width * x + maxh - maxh / height * y) / 2; + pixel->opacity = (opacity <= MaxRGB) ? opacity : MaxRGB; + } + } + imgblend.syncPixels(); + + Image imgback(Geometry(width, height), Back); + imgback.composite(imgblend, 0, 0, OverCompositeOp); + + buffer = imgback; } +void cImageMagickWrapper::CreateBackground(tColor back, tColor blend, int width, int height, bool mirror) { + CreateGradient(back, blend, width, height, 0.8, 0.8); + if (mirror) + buffer.flop(); +} void cImageMagickWrapper::CreateBackgroundReverse(tColor back, tColor blend, int width, int height) { - Color Back = Argb2Color(back); - Color Blend = Argb2Color(blend); - Image tmp(Geometry(width, height), Blend); - double arguments[9] = {0.0,(double)height,0.0,-0.5*(double)width,0.0,0.0,(double)width,0.0,1.0}; - tmp.sparseColor(MatteChannel, BarycentricColorInterpolate, 9, arguments); - Image tmp2(Geometry(width, height), Back); - tmp.composite(tmp2, 0, 0, OverlayCompositeOp); - buffer = tmp; + CreateGradient(back, blend, width, height, 1.3, 0.7); } - diff --git a/imagemagickwrapper.h b/imagemagickwrapper.h index 1c38074..a5cc482 100644 --- a/imagemagickwrapper.h +++ b/imagemagickwrapper.h @@ -9,6 +9,8 @@ using namespace Magick; class cImageMagickWrapper { +private: + void CreateGradient(tColor back, tColor blend, int width, int height, double wfactor, double hfactor); public: cImageMagickWrapper(); ~cImageMagickWrapper(); |