From 3952cad3d41c236640ef159825be81eba6c3116d Mon Sep 17 00:00:00 2001 From: Manuel Reimer Date: Sun, 22 Dec 2013 10:39:46 +0100 Subject: [PATCH] implemented GraphicsMagick compatibility --- HISTORY | 4 ++++ Makefile | 15 ++++++++++----- imageloader.c | 34 ++++++++++++++++++++++++++-------- imageloader.h | 2 ++ 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/HISTORY b/HISTORY index 3933e3a..77b9352 100644 --- a/HISTORY +++ b/HISTORY @@ -80,3 +80,7 @@ Version 1.1.0 -l logo directory - changed detailed epg view using full screen, some further optimisations - search for _0.jpg beside .jpg as epg image +- implemented GraphicsMagick compatibility (thanks @Manuel Reimer + for providing the patch) +- changed Makefile to support both ImageMagick and GraphicsMagick + (configurable in Makefile) diff --git a/Makefile b/Makefile index 176ad7d..01d28ac 100644 --- a/Makefile +++ b/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. @@ -44,13 +47,15 @@ SOFILE = libvdr-$(PLUGIN).so ### Includes and Defines (add further entries here): -INCLUDES += $(shell pkg-config --cflags-only-I Magick++) - DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -DEFINES += -DMAGICKCORE_HDRI_ENABLE=0 -DEFINES += -DMAGICKCORE_QUANTUM_DEPTH=16 -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/imageloader.c b/imageloader.c index 2faeb91..d194295 100644 --- a/imageloader.c +++ b/imageloader.c @@ -101,14 +101,7 @@ bool cImageLoader::LoadOsdElement(cString name, int width, int height) { bool cImageLoader::DrawBackground(tColor back, tColor blend, int width, int height) { if ((width < 1) || (height < 1) || (width > 1920) || (height > 1080)) return false; - 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); - buffer = tmp; + CreateGradient(back, blend, width, height, 0.8, 0.8); return true; } @@ -130,3 +123,28 @@ cImage cImageLoader::GetImage() { } return image; } + +void cImageLoader::CreateGradient(tColor back, tColor blend, int width, int height, double wfactor, double hfactor) { + Color Back = Argb2Color(back); + Color Blend = Argb2Color(blend); + 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; +} \ No newline at end of file diff --git a/imageloader.h b/imageloader.h index f06b542..942986f 100644 --- a/imageloader.h +++ b/imageloader.h @@ -22,6 +22,8 @@ public: bool LoadIcon(const char *cIcon, int size); bool LoadOsdElement(cString name, int width, int height); bool DrawBackground(tColor back, tColor blend, int width, int height); +private: + void CreateGradient(tColor back, tColor blend, int width, int height, double wfactor, double hfactor); }; #endif //_TVGUIDE_IMAGELOADER_H