summaryrefslogtreecommitdiff
path: root/imagemagickwrapper.c
diff options
context:
space:
mode:
authorManuel Reimer <manuel.reimer@gmx.de>2013-11-12 17:03:11 +0100
committerlouis <louis.braun@gmx.de>2013-11-12 17:03:11 +0100
commit735f22370b0d48c8c121a31c115e9d72af895eca (patch)
treef947bcec75ebf52ce78ec59071944a2a2ed55f0f /imagemagickwrapper.c
parent09a6323046f959a748a6a15fc2aa1e1af1ffba7c (diff)
downloadskin-nopacity-735f22370b0d48c8c121a31c115e9d72af895eca.tar.gz
skin-nopacity-735f22370b0d48c8c121a31c115e9d72af895eca.tar.bz2
implemented GraphicsMagick compatibility
Diffstat (limited to 'imagemagickwrapper.c')
-rw-r--r--imagemagickwrapper.c45
1 files changed, 27 insertions, 18 deletions
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);
}
-