This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project wmaker-crm.git.
The branch, next has been updated
via 35a43c9430442264b62ba4806dc59ac33988db18 (commit)
from dda7f484072d04e6235a354307dd1199c6136fd4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/wmaker-crm.git/commit/35a43c9430442264b62ba4806dc59ac33988db18
commit 35a43c9430442264b62ba4806dc59ac33988db18
Author: David Maciejak <[email protected]>
Date: Mon May 26 22:42:44 2014 +0800
wrlib: fixed transformation functions
With a set of images i was able to detect that
the flip functions was shifting the image by 1px.
The 90 and 270 degrees rotation were not working as
the functions were also mirroring the img.
The patch is also fixing the C style based on checkpatch.
diff --git a/wrlib/flip.c b/wrlib/flip.c
index 6801783c..f49bfd96 100644
--- a/wrlib/flip.c
+++ b/wrlib/flip.c
@@ -43,42 +43,42 @@ RImage *RVerticalFlipImage(RImage *image)
return NULL;
if (bpp == 3) {
- unsigned char *optr, *nptr;
-
- optr = image->data;
- nptr = img->data + 4 * (nwidth * nheight - nwidth - 1);
-
- for (y = 0; y < nheight; y++) {
- for (x = 0; x < nwidth; x++) {
- nptr[0] = optr[0];
- nptr[1] = optr[1];
- nptr[2] = optr[2];
- nptr[3] = 255;
-
- optr += 3;
- nptr += 4;
- }
- nptr -= nwidth*8;
+ unsigned char *optr, *nptr;
+
+ optr = image->data;
+ nptr = img->data + 4 * (nwidth * nheight - nwidth);
+
+ for (y = 0; y < nheight; y++) {
+ for (x = 0; x < nwidth; x++) {
+ nptr[0] = optr[0];
+ nptr[1] = optr[1];
+ nptr[2] = optr[2];
+ nptr[3] = 255;
+
+ optr += 3;
+ nptr += 4;
}
- } else {
- unsigned char *optr, *nptr;
-
- optr = image->data;
- nptr = img->data + 4 * (nwidth * nheight - nwidth - 1);
-
- for (y = 0; y < nheight; y++) {
- for (x = 0; x < nwidth; x++) {
- nptr[0] = optr[0];
- nptr[1] = optr[1];
- nptr[2] = optr[2];
- nptr[3] = optr[3];
-
- optr += 4;
- nptr += 4;
- }
- nptr -= nwidth*8;
+ nptr -= nwidth*8;
+ }
+ } else {
+ unsigned char *optr, *nptr;
+
+ optr = image->data;
+ nptr = img->data + 4 * (nwidth * nheight - nwidth);
+
+ for (y = 0; y < nheight; y++) {
+ for (x = 0; x < nwidth; x++) {
+ nptr[0] = optr[0];
+ nptr[1] = optr[1];
+ nptr[2] = optr[2];
+ nptr[3] = optr[3];
+
+ optr += 4;
+ nptr += 4;
}
+ nptr -= nwidth * 8;
}
+ }
return img;
}
@@ -97,37 +97,41 @@ RImage *RHorizontalFlipImage(RImage *image)
return NULL;
if (bpp == 3) {
- unsigned char *optr, *nptr;
+ unsigned char *optr, *nptr;
- nptr = img->data + nwidth * nheight * 4 - 4;
- for (y = nheight; y; y--) {
- for (x = 0; x < nwidth; x++) {
- optr = image->data + (y*nwidth + x) * 3;
+ optr = image->data;
+ nptr = img->data + 4 * (nwidth - 1);
- nptr[0] = optr[0];
- nptr[1] = optr[1];
- nptr[2] = optr[2];
- nptr[3] = 255;
+ for (y = nheight; y; y--) {
+ for (x = 0; x < nwidth; x++) {
+ nptr[0] = optr[0];
+ nptr[1] = optr[1];
+ nptr[2] = optr[2];
+ nptr[3] = 255;
- nptr -= 4;
- }
+ optr += 3;
+ nptr -= 4;
}
- } else {
- unsigned char *optr, *nptr;
+ nptr += 8 * nwidth;
+ }
+ } else {
+ unsigned char *optr, *nptr;
- nptr = img->data + nwidth * nheight * 4 - 4;
- for (y = nheight; y; y--) {
- for (x = 0; x < nwidth; x++) {
- optr = image->data + (y*nwidth + x) * 4;
+ optr = image->data;
+ nptr = img->data + 4 * (nwidth - 1);
- nptr[0] = optr[0];
- nptr[1] = optr[1];
- nptr[2] = optr[2];
- nptr[3] = optr[3];
+ for (y = nheight; y; y--) {
+ for (x = 0; x < nwidth; x++) {
+ nptr[0] = optr[0];
+ nptr[1] = optr[1];
+ nptr[2] = optr[2];
+ nptr[3] = optr[3];
- nptr -= 4;
- }
+ optr += 4;
+ nptr -= 4;
}
+ nptr += 8 * nwidth;
}
+ }
return img;
}
diff --git a/wrlib/rotate.c b/wrlib/rotate.c
index 09e8a0ad..f2f92b99 100644
--- a/wrlib/rotate.c
+++ b/wrlib/rotate.c
@@ -34,9 +34,9 @@
#define PI 3.14159265358979323846
#endif
-static RImage *rotateImage(RImage * image, float angle);
+static RImage *rotateImage(RImage *image, float angle);
-RImage *RRotateImage(RImage * image, float angle)
+RImage *RRotateImage(RImage *image, float angle)
{
RImage *img;
int nwidth, nheight;
@@ -66,40 +66,41 @@ RImage *RRotateImage(RImage * image, float angle)
nheight = image->width;
img = RCreateImage(nwidth, nheight, True);
- if (!img) {
+ if (!img)
return NULL;
- }
if (bpp == 3) {
unsigned char *optr, *nptr;
- unsigned offs;
-
- offs = nwidth * 4;
optr = image->data;
+ nptr = img->data;
- for (x = 0; x < nwidth; x++) {
- nptr = img->data + x * 4;
+ for (x = nwidth; x; x--) {
+ nptr = img->data + 4 * (x - 1);
for (y = nheight; y; y--) {
nptr[0] = *optr++;
nptr[1] = *optr++;
nptr[2] = *optr++;
nptr[3] = 255;
- nptr += offs;
+ nptr += 4 * nwidth;
}
}
} else {
- unsigned *optr, *nptr;
- unsigned *p;
+ unsigned char *optr, *nptr;
- optr = (unsigned *)image->data;
- p = (unsigned *)img->data;
- for (x = 0; x < nwidth; x++) {
- nptr = p++;
+ optr = image->data;
+ nptr = img->data;
+
+ for (x = nwidth; x; x--) {
+ nptr = img->data + 4 * (x - 1);
for (y = nheight; y; y--) {
- *nptr = *optr++;
- nptr += nwidth;
+ nptr[0] = *optr++;
+ nptr[1] = *optr++;
+ nptr[2] = *optr++;
+ nptr[3] = *optr++;
+
+ nptr += 4 * nwidth;
}
}
}
@@ -109,9 +110,8 @@ RImage *RRotateImage(RImage * image, float angle)
nwidth = image->width;
nheight = image->height;
img = RCreateImage(nwidth, nheight, True);
- if (!img) {
+ if (!img)
return NULL;
- }
if (bpp == 3) {
unsigned char *optr, *nptr;
@@ -148,40 +148,39 @@ RImage *RRotateImage(RImage * image, float angle)
nheight = image->width;
img = RCreateImage(nwidth, nheight, True);
- if (!img) {
+ if (!img)
return NULL;
- }
if (bpp == 3) {
unsigned char *optr, *nptr;
- unsigned offs;
-
- offs = nwidth * 4;
optr = image->data;
- for (x = 0; x < nwidth; x++) {
- nptr = img->data + x * 4;
+ for (x = nwidth; x; x--) {
+ nptr = img->data + 4 * nwidth * nheight - x * 4;
for (y = nheight; y; y--) {
nptr[0] = *optr++;
nptr[1] = *optr++;
nptr[2] = *optr++;
nptr[3] = 255;
- nptr += offs;
+ nptr -= 4 * nwidth;
}
}
} else {
- unsigned *optr, *nptr;
- unsigned *p;
+ unsigned char *optr, *nptr;
- optr = (unsigned *)image->data;
- p = (unsigned *)img->data + nwidth * nheight;
- for (x = 0; x < nwidth; x++) {
- nptr = p--;
+ optr = image->data;
+
+ for (x = nwidth; x; x--) {
+ nptr = img->data + 4 * nwidth * nheight - x * 4;
for (y = nheight; y; y--) {
- *nptr = *optr++;
- nptr -= nwidth;
+ nptr[0] = *optr++;
+ nptr[1] = *optr++;
+ nptr[2] = *optr++;
+ nptr[3] = *optr++;
+
+ nptr -= 4 * nwidth;
}
}
}
@@ -209,7 +208,7 @@ RImage *RRotateImage(RImage * image, float angle)
* for each point P1 in the line from C to A
* for each point P2 in the perpendicular line starting at P1
* get pixel from the source and plot at P2
- * increment pixel location from source
+ * increment pixel location from source
*
*/
@@ -295,7 +294,7 @@ copyLine(int x1, int y1, int x2, int y2, int nwidth, int
format, unsigned char *
}
#endif
-static RImage *rotateImage(RImage * image, float angle)
+static RImage *rotateImage(RImage *image, float angle)
{
(void) angle;
puts("NOT FULLY IMPLEMENTED");
-----------------------------------------------------------------------
Summary of changes:
wrlib/flip.c | 116 +++++++++++++++++++++++++++++---------------------------
wrlib/rotate.c | 75 ++++++++++++++++++------------------
2 files changed, 97 insertions(+), 94 deletions(-)
repo.or.cz automatic notification. Contact project admin [email protected]
if you want to unsubscribe, or site admin [email protected] if you receive
no reply.
--
wmaker-crm.git ("The Window Maker window manager")
--
To unsubscribe, send mail to [email protected].