|
|
@@ -60,3 +60,75 @@ pipi_image_t *pipi_rgb(pipi_image_t *i1, pipi_image_t *i2, pipi_image_t *i3) |
|
|
|
return dst; |
|
|
|
} |
|
|
|
|
|
|
|
pipi_image_t *pipi_red(pipi_image_t *src) |
|
|
|
{ |
|
|
|
pipi_image_t *dst; |
|
|
|
pipi_pixels_t *srcp, *dstp; |
|
|
|
float *srcdata, *dstdata; |
|
|
|
int x, y, w, h; |
|
|
|
|
|
|
|
w = src->w; |
|
|
|
h = src->h; |
|
|
|
|
|
|
|
dst = pipi_new(w, h); |
|
|
|
dstp = pipi_getpixels(dst, PIPI_PIXELS_Y_F); |
|
|
|
dstdata = (float *)dstp->pixels; |
|
|
|
|
|
|
|
srcp = pipi_getpixels(src, PIPI_PIXELS_RGBA_F); |
|
|
|
srcdata = (float *)srcp->pixels; |
|
|
|
|
|
|
|
for(y = 0; y < h; y++) |
|
|
|
for(x = 0; x < w; x++) |
|
|
|
dstdata[y * w + x] = srcdata[4 * (y * w + x)]; |
|
|
|
|
|
|
|
return dst; |
|
|
|
} |
|
|
|
|
|
|
|
pipi_image_t *pipi_green(pipi_image_t *src) |
|
|
|
{ |
|
|
|
pipi_image_t *dst; |
|
|
|
pipi_pixels_t *srcp, *dstp; |
|
|
|
float *srcdata, *dstdata; |
|
|
|
int x, y, w, h; |
|
|
|
|
|
|
|
w = src->w; |
|
|
|
h = src->h; |
|
|
|
|
|
|
|
dst = pipi_new(w, h); |
|
|
|
dstp = pipi_getpixels(dst, PIPI_PIXELS_Y_F); |
|
|
|
dstdata = (float *)dstp->pixels; |
|
|
|
|
|
|
|
srcp = pipi_getpixels(src, PIPI_PIXELS_RGBA_F); |
|
|
|
srcdata = (float *)srcp->pixels; |
|
|
|
|
|
|
|
for(y = 0; y < h; y++) |
|
|
|
for(x = 0; x < w; x++) |
|
|
|
dstdata[y * w + x] = srcdata[4 * (y * w + x) + 1]; |
|
|
|
|
|
|
|
return dst; |
|
|
|
} |
|
|
|
|
|
|
|
pipi_image_t *pipi_blue(pipi_image_t *src) |
|
|
|
{ |
|
|
|
pipi_image_t *dst; |
|
|
|
pipi_pixels_t *srcp, *dstp; |
|
|
|
float *srcdata, *dstdata; |
|
|
|
int x, y, w, h; |
|
|
|
|
|
|
|
w = src->w; |
|
|
|
h = src->h; |
|
|
|
|
|
|
|
dst = pipi_new(w, h); |
|
|
|
dstp = pipi_getpixels(dst, PIPI_PIXELS_Y_F); |
|
|
|
dstdata = (float *)dstp->pixels; |
|
|
|
|
|
|
|
srcp = pipi_getpixels(src, PIPI_PIXELS_RGBA_F); |
|
|
|
srcdata = (float *)srcp->pixels; |
|
|
|
|
|
|
|
for(y = 0; y < h; y++) |
|
|
|
for(x = 0; x < w; x++) |
|
|
|
dstdata[y * w + x] = srcdata[4 * (y * w + x) + 2]; |
|
|
|
|
|
|
|
return dst; |
|
|
|
} |
|
|
|
|