|
|
@@ -23,16 +23,23 @@ |
|
|
|
#include "pipi.h" |
|
|
|
#include "pipi_internals.h" |
|
|
|
|
|
|
|
pipi_image_t *pipi_mean(pipi_image_t *img1, pipi_image_t *img2) |
|
|
|
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) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
if(t < 0.0) |
|
|
|
t = 0.0; |
|
|
|
else if(t > 1.0) |
|
|
|
t = 1.0; |
|
|
|
t2 = 1.0 - t; |
|
|
|
|
|
|
|
w = img1->w; |
|
|
|
h = img1->h; |
|
|
|
|
|
|
@@ -53,22 +60,27 @@ pipi_image_t *pipi_mean(pipi_image_t *img1, pipi_image_t *img2) |
|
|
|
|
|
|
|
p = img1data[4 * (y * w + x)]; |
|
|
|
q = img2data[4 * (y * w + x)]; |
|
|
|
dstdata[4 * (y * w + x)] = (p + q) * 0.5; |
|
|
|
dstdata[4 * (y * w + x)] = t * p + t2 * q; |
|
|
|
|
|
|
|
p = img1data[4 * (y * w + x) + 1]; |
|
|
|
q = img2data[4 * (y * w + x) + 1]; |
|
|
|
dstdata[4 * (y * w + x) + 1] = (p + q) * 0.5; |
|
|
|
dstdata[4 * (y * w + x) + 1] = t * p + t2 * q; |
|
|
|
|
|
|
|
p = img1data[4 * (y * w + x) + 2]; |
|
|
|
q = img2data[4 * (y * w + x) + 2]; |
|
|
|
dstdata[4 * (y * w + x) + 2] = (p + q) * 0.5; |
|
|
|
dstdata[4 * (y * w + x) + 2] = t * p + t2 * q; |
|
|
|
|
|
|
|
p = img1data[4 * (y * w + x) + 3]; |
|
|
|
q = img2data[4 * (y * w + x) + 3]; |
|
|
|
dstdata[4 * (y * w + x) + 3] = (p + q) * 0.5; |
|
|
|
dstdata[4 * (y * w + x) + 3] = t * p + t2 * q; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return dst; |
|
|
|
} |
|
|
|
|
|
|
|
pipi_image_t *pipi_mean(pipi_image_t *img1, pipi_image_t *img2) |
|
|
|
{ |
|
|
|
return pipi_merge(img1, img2, 0.5); |
|
|
|
} |
|
|
|
|