From f0b0a8ba0a526a1f8a47555dc60ffce634542ab9 Mon Sep 17 00:00:00 2001 From: sam Date: Wed, 8 Jul 2009 23:38:32 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20the=20pipi=5Fmerge()=20semantics=20so=20t?= =?UTF-8?q?hat=20it=20matches=20Gimp=E2=80=99s,=20and=20don=E2=80=99t=20ig?= =?UTF-8?q?nore=20the=20image=E2=80=99s=20alpha=20layers.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@3545 92316355-f0b4-4df1-b90c-862c8a59935f --- pipi/combine/merge.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pipi/combine/merge.c b/pipi/combine/merge.c index dd6f7b9..2d44c05 100644 --- a/pipi/combine/merge.c +++ b/pipi/combine/merge.c @@ -28,7 +28,6 @@ pipi_image_t *pipi_merge(pipi_image_t *img1, pipi_image_t *img2, double t) pipi_image_t *dst; pipi_pixels_t *img1p, *img2p, *dstp; float *img1data, *img2data, *dstdata; - double t2; int x, y, w, h; if(img1->w != img2->w || img1->h != img2->h) @@ -38,7 +37,6 @@ pipi_image_t *pipi_merge(pipi_image_t *img1, pipi_image_t *img2, double t) t = 0.0; else if(t > 1.0) t = 1.0; - t2 = 1.0 - t; w = img1->w; h = img1->h; @@ -57,22 +55,24 @@ pipi_image_t *pipi_merge(pipi_image_t *img1, pipi_image_t *img2, double t) for(x = 0; x < w; x++) { float p, q; + double t1 = t * img2data[4 * (y * w + x) + 3]; + double t2 = 1.0 - t1; p = img1data[4 * (y * w + x)]; q = img2data[4 * (y * w + x)]; - dstdata[4 * (y * w + x)] = t * p + t2 * q; + dstdata[4 * (y * w + x)] = t2 * p + t1 * q; p = img1data[4 * (y * w + x) + 1]; q = img2data[4 * (y * w + x) + 1]; - dstdata[4 * (y * w + x) + 1] = t * p + t2 * q; + dstdata[4 * (y * w + x) + 1] = t2 * p + t1 * q; p = img1data[4 * (y * w + x) + 2]; q = img2data[4 * (y * w + x) + 2]; - dstdata[4 * (y * w + x) + 2] = t * p + t2 * q; + dstdata[4 * (y * w + x) + 2] = t2 * p + t1 * q; p = img1data[4 * (y * w + x) + 3]; q = img2data[4 * (y * w + x) + 3]; - dstdata[4 * (y * w + x) + 3] = t * p + t2 * q; + dstdata[4 * (y * w + x) + 3] = t2 * p + t1 * q; } }