|
|
@@ -78,7 +78,7 @@ pipi_image_t *pipi_vflip(pipi_image_t *src) |
|
|
|
pipi_image_t *dst; |
|
|
|
pipi_pixels_t *srcp, *dstp; |
|
|
|
float *srcdata, *dstdata; |
|
|
|
int x, y, w, h, gray; |
|
|
|
int y, w, h, gray; |
|
|
|
|
|
|
|
w = src->w; |
|
|
|
h = src->h; |
|
|
@@ -113,3 +113,141 @@ pipi_image_t *pipi_vflip(pipi_image_t *src) |
|
|
|
return dst; |
|
|
|
} |
|
|
|
|
|
|
|
pipi_image_t *pipi_rotate90(pipi_image_t *src) |
|
|
|
{ |
|
|
|
pipi_image_t *dst; |
|
|
|
pipi_pixels_t *srcp, *dstp; |
|
|
|
float *srcdata, *dstdata; |
|
|
|
int x, y, w, h, gray; |
|
|
|
|
|
|
|
w = src->w; |
|
|
|
h = src->h; |
|
|
|
|
|
|
|
gray = (src->last_modified == PIPI_PIXELS_Y_F); |
|
|
|
|
|
|
|
srcp = gray ? pipi_getpixels(src, PIPI_PIXELS_Y_F) |
|
|
|
: pipi_getpixels(src, PIPI_PIXELS_RGBA_F); |
|
|
|
srcdata = (float *)srcp->pixels; |
|
|
|
|
|
|
|
dst = pipi_new(h, w); |
|
|
|
dstp = gray ? pipi_getpixels(dst, PIPI_PIXELS_Y_F) |
|
|
|
: pipi_getpixels(dst, PIPI_PIXELS_RGBA_F); |
|
|
|
dstdata = (float *)dstp->pixels; |
|
|
|
|
|
|
|
for(y = 0; y < h; y++) |
|
|
|
{ |
|
|
|
for(x = 0; x < w; x++) |
|
|
|
{ |
|
|
|
if(gray) |
|
|
|
{ |
|
|
|
dstdata[x * h + y] = srcdata[y * w + w - 1 - x]; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
dstdata[4 * (x * h + y)] |
|
|
|
= srcdata[4 * (y * w + w - 1 - x)]; |
|
|
|
dstdata[4 * (x * h + y) + 1] |
|
|
|
= srcdata[4 * (y * w + w - 1 - x) + 1]; |
|
|
|
dstdata[4 * (x * h + y) + 2] |
|
|
|
= srcdata[4 * (y * w + w - 1 - x) + 2]; |
|
|
|
dstdata[4 * (x * h + y) + 3] |
|
|
|
= srcdata[4 * (y * w + w - 1 - x) + 3]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return dst; |
|
|
|
} |
|
|
|
|
|
|
|
pipi_image_t *pipi_rotate180(pipi_image_t *src) |
|
|
|
{ |
|
|
|
pipi_image_t *dst; |
|
|
|
pipi_pixels_t *srcp, *dstp; |
|
|
|
float *srcdata, *dstdata; |
|
|
|
int x, y, w, h, gray; |
|
|
|
|
|
|
|
w = src->w; |
|
|
|
h = src->h; |
|
|
|
|
|
|
|
gray = (src->last_modified == PIPI_PIXELS_Y_F); |
|
|
|
|
|
|
|
srcp = gray ? pipi_getpixels(src, PIPI_PIXELS_Y_F) |
|
|
|
: pipi_getpixels(src, PIPI_PIXELS_RGBA_F); |
|
|
|
srcdata = (float *)srcp->pixels; |
|
|
|
|
|
|
|
dst = pipi_new(w, h); |
|
|
|
dstp = gray ? pipi_getpixels(dst, PIPI_PIXELS_Y_F) |
|
|
|
: pipi_getpixels(dst, PIPI_PIXELS_RGBA_F); |
|
|
|
dstdata = (float *)dstp->pixels; |
|
|
|
|
|
|
|
for(y = 0; y < h; y++) |
|
|
|
{ |
|
|
|
for(x = 0; x < w; x++) |
|
|
|
{ |
|
|
|
if(gray) |
|
|
|
{ |
|
|
|
dstdata[y * w + x] = srcdata[(h - 1 - y) * w + (w - 1 - x)]; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
dstdata[4 * (y * w + x)] |
|
|
|
= srcdata[4 * ((h - 1 - y) * w + (w - 1 - x))]; |
|
|
|
dstdata[4 * (y * w + x) + 1] |
|
|
|
= srcdata[4 * ((h - 1 - y) * w + (w - 1 - x)) + 1]; |
|
|
|
dstdata[4 * (y * w + x) + 2] |
|
|
|
= srcdata[4 * ((h - 1 - y) * w + (w - 1 - x)) + 2]; |
|
|
|
dstdata[4 * (y * w + x) + 3] |
|
|
|
= srcdata[4 * ((h - 1 - y) * w + (w - 1 - x)) + 3]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return dst; |
|
|
|
} |
|
|
|
|
|
|
|
pipi_image_t *pipi_rotate270(pipi_image_t *src) |
|
|
|
{ |
|
|
|
pipi_image_t *dst; |
|
|
|
pipi_pixels_t *srcp, *dstp; |
|
|
|
float *srcdata, *dstdata; |
|
|
|
int x, y, w, h, gray; |
|
|
|
|
|
|
|
w = src->w; |
|
|
|
h = src->h; |
|
|
|
|
|
|
|
gray = (src->last_modified == PIPI_PIXELS_Y_F); |
|
|
|
|
|
|
|
srcp = gray ? pipi_getpixels(src, PIPI_PIXELS_Y_F) |
|
|
|
: pipi_getpixels(src, PIPI_PIXELS_RGBA_F); |
|
|
|
srcdata = (float *)srcp->pixels; |
|
|
|
|
|
|
|
dst = pipi_new(h, w); |
|
|
|
dstp = gray ? pipi_getpixels(dst, PIPI_PIXELS_Y_F) |
|
|
|
: pipi_getpixels(dst, PIPI_PIXELS_RGBA_F); |
|
|
|
dstdata = (float *)dstp->pixels; |
|
|
|
|
|
|
|
for(y = 0; y < h; y++) |
|
|
|
{ |
|
|
|
for(x = 0; x < w; x++) |
|
|
|
{ |
|
|
|
if(gray) |
|
|
|
{ |
|
|
|
dstdata[x * h + h - 1 - y] = srcdata[y * w + x]; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
dstdata[4 * (x * h + h - 1 - y)] |
|
|
|
= srcdata[4 * (y * w + x)]; |
|
|
|
dstdata[4 * (x * h + h - 1 - y) + 1] |
|
|
|
= srcdata[4 * (y * w + x) + 1]; |
|
|
|
dstdata[4 * (x * h + h - 1 - y) + 2] |
|
|
|
= srcdata[4 * (y * w + x) + 2]; |
|
|
|
dstdata[4 * (x * h + h - 1 - y) + 3] |
|
|
|
= srcdata[4 * (y * w + x) + 3]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return dst; |
|
|
|
} |
|
|
|
|