1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-30 20:35:49 +01:00

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.
This commit is contained in:
David Maciejak
2014-05-26 22:42:44 +08:00
committed by Carlos R. Mafra
parent dda7f48407
commit 35a43c9430
2 changed files with 99 additions and 96 deletions

View File

@@ -43,42 +43,42 @@ RImage *RVerticalFlipImage(RImage *image)
return NULL;
if (bpp == 3) {
unsigned char *optr, *nptr;
unsigned char *optr, *nptr;
optr = image->data;
nptr = img->data + 4 * (nwidth * nheight - nwidth - 1);
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;
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;
}
} 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;
optr += 3;
nptr += 4;
}
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;
}
}
} 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;
nptr[0] = optr[0];
nptr[1] = optr[1];
nptr[2] = optr[2];
nptr[3] = optr[3];
nptr -= 4;
}
optr += 3;
nptr -= 4;
}
nptr += 8 * nwidth;
}
} else {
unsigned char *optr, *nptr;
optr = image->data;
nptr = img->data + 4 * (nwidth - 1);
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];
optr += 4;
nptr -= 4;
}
nptr += 8 * nwidth;
}
}
return img;
}