瀏覽代碼

* rgb.c: implement pipi_red(), pipi_green() and pipi_blue() to extract

separate channels.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2754 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 年之前
父節點
當前提交
6433a59c97
共有 2 個文件被更改,包括 75 次插入0 次删除
  1. +72
    -0
      pipi/combine/rgb.c
  2. +3
    -0
      pipi/pipi.h

+ 72
- 0
pipi/combine/rgb.c 查看文件

@@ -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;
}


+ 3
- 0
pipi/pipi.h 查看文件

@@ -106,6 +106,9 @@ extern double pipi_measure_rmsd(pipi_image_t *, pipi_image_t *);
extern pipi_image_t *pipi_resize(pipi_image_t *, int, int);

extern pipi_image_t *pipi_rgb(pipi_image_t *, pipi_image_t *, pipi_image_t *);
extern pipi_image_t *pipi_red(pipi_image_t *);
extern pipi_image_t *pipi_green(pipi_image_t *);
extern pipi_image_t *pipi_blue(pipi_image_t *);
extern pipi_image_t *pipi_mean(pipi_image_t *, pipi_image_t *);
extern pipi_image_t *pipi_min(pipi_image_t *, pipi_image_t *);
extern pipi_image_t *pipi_max(pipi_image_t *, pipi_image_t *);


Loading…
取消
儲存