From f2dea1b84060a6bf92d30906cdf9c8d4c2b10a44 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Fri, 4 Jul 2014 23:28:35 +0200 Subject: [PATCH] wrlib: code refactoring in RFlipImage functions Instead of calling all variables with variants of 'image', changed the name to reflect what image it is about for clarity. Signed-off-by: Christophe CURIS --- wrlib/flip.c | 60 +++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/wrlib/flip.c b/wrlib/flip.c index f49bfd96..03d6166a 100644 --- a/wrlib/flip.c +++ b/wrlib/flip.c @@ -20,33 +20,35 @@ * MA 02110-1301, USA. */ -#include +#include "config.h" #include #include #include + #include + #include "wraster.h" -RImage *RVerticalFlipImage(RImage *image) +RImage *RVerticalFlipImage(RImage *source) { - RImage *img; + RImage *target; int nwidth, nheight; int x, y; - int bpp = image->format == RRGBAFormat ? 4 : 3; + int bpp = source->format == RRGBAFormat ? 4 : 3; - nwidth = image->width; - nheight = image->height; + nwidth = source->width; + nheight = source->height; - img = RCreateImage(nwidth, nheight, True); - if (!img) + target = RCreateImage(nwidth, nheight, True); + if (!target) return NULL; if (bpp == 3) { unsigned char *optr, *nptr; - optr = image->data; - nptr = img->data + 4 * (nwidth * nheight - nwidth); + optr = source->data; + nptr = target->data + 4 * (nwidth * nheight - nwidth); for (y = 0; y < nheight; y++) { for (x = 0; x < nwidth; x++) { @@ -58,13 +60,13 @@ RImage *RVerticalFlipImage(RImage *image) optr += 3; nptr += 4; } - nptr -= nwidth*8; + nptr -= (nwidth * 4) * 2; } } else { unsigned char *optr, *nptr; - optr = image->data; - nptr = img->data + 4 * (nwidth * nheight - nwidth); + optr = source->data; + nptr = target->data + 4 * (nwidth * nheight - nwidth); for (y = 0; y < nheight; y++) { for (x = 0; x < nwidth; x++) { @@ -76,31 +78,31 @@ RImage *RVerticalFlipImage(RImage *image) optr += 4; nptr += 4; } - nptr -= nwidth * 8; + nptr -= (nwidth * 4) * 2; } } - return img; + return target; } -RImage *RHorizontalFlipImage(RImage *image) +RImage *RHorizontalFlipImage(RImage *source) { - RImage *img; + RImage *target; int nwidth, nheight; int x, y; - int bpp = image->format == RRGBAFormat ? 4 : 3; + int bpp = source->format == RRGBAFormat ? 4 : 3; - nwidth = image->width; - nheight = image->height; + nwidth = source->width; + nheight = source->height; - img = RCreateImage(nwidth, nheight, True); - if (!img) + target = RCreateImage(nwidth, nheight, True); + if (!target) return NULL; if (bpp == 3) { unsigned char *optr, *nptr; - optr = image->data; - nptr = img->data + 4 * (nwidth - 1); + optr = source->data; + nptr = target->data + 4 * (nwidth - 1); for (y = nheight; y; y--) { for (x = 0; x < nwidth; x++) { @@ -112,13 +114,13 @@ RImage *RHorizontalFlipImage(RImage *image) optr += 3; nptr -= 4; } - nptr += 8 * nwidth; + nptr += (nwidth * 4) * 2; } } else { unsigned char *optr, *nptr; - optr = image->data; - nptr = img->data + 4 * (nwidth - 1); + optr = source->data; + nptr = target->data + 4 * (nwidth - 1); for (y = nheight; y; y--) { for (x = 0; x < nwidth; x++) { @@ -130,8 +132,8 @@ RImage *RHorizontalFlipImage(RImage *image) optr += 4; nptr -= 4; } - nptr += 8 * nwidth; + nptr += (nwidth * 4) * 2; } } - return img; + return target; }