diff options
author | Manuel Reimer <manuel.reimer@gmx.de> | 2013-12-22 10:39:46 +0100 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2013-12-22 10:39:46 +0100 |
commit | 3952cad3d41c236640ef159825be81eba6c3116d (patch) | |
tree | 38f60249986227330ca845f3d684b75f86ef1732 /imageloader.c | |
parent | 5bf7c3a84e683a8226256a41292566789fd29521 (diff) | |
download | vdr-plugin-tvguide-3952cad3d41c236640ef159825be81eba6c3116d.tar.gz vdr-plugin-tvguide-3952cad3d41c236640ef159825be81eba6c3116d.tar.bz2 |
implemented GraphicsMagick compatibility
Diffstat (limited to 'imageloader.c')
-rw-r--r-- | imageloader.c | 34 |
1 files changed, 26 insertions, 8 deletions
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 |