cvs: gd /libgd/examples CMakeLists.txt flip.c /libgd/src gd_tga.c gd_transform.c
[email protected] ("Pierre-Alain Joye") Wed, 27 Feb 2008 23:25:00 -0000
| Newsgroups | php.gd.cvs |
|---|---|
| Message-ID | <cvspajoye1204154700@cvsserver> |
pajoye Wed Feb 27 23:25:00 2008 UTC
Added files:
/gd/libgd/examples flip.c
Modified files:
/gd/libgd/src gd_transform.c gd_tga.c
/gd/libgd/examples CMakeLists.txt
Log:
- #129:
- revert horizontal/vertical, was too confusing, it acts now like any
application (ie. gimp/ps) instead of talking about h/v axis
- optimize both
- add simple example
http://cvs.php.net/viewvc.cgi/gd/libgd/src/gd_transform.c?r1=1.4&r2=1.5&diff_format=u
Index: gd/libgd/src/gd_transform.c
diff -u gd/libgd/src/gd_transform.c:1.4 gd/libgd/src/gd_transform.c:1.5
--- gd/libgd/src/gd_transform.c:1.4 Fri Dec 28 16:51:35 2007
+++ gd/libgd/src/gd_transform.c Wed Feb 27 23:24:59 2008
@@ -1,18 +1,18 @@
#include "gd.h"
-BGD_DECLARE(void)
-gdImageFlipHorizontal(gdImagePtr im)
+BGD_DECLARE(void) gdImageFlipVertical(gdImagePtr im)
{
register int x, y;
-
if (im->trueColor) {
- int p;
for (y = 0; y < im->sy / 2; y++) {
+ int *row_dst = im->tpixels[y];
+ int *row_src = im->tpixels[im->sy - 1 - y];
for (x = 0; x < im->sx; x++) {
- p = im->tpixels[y][x];
- im->tpixels[y][x] = im->tpixels[im->sy - 1 - y][x];
- im->tpixels[im->sy - 1 - y][x] = p;
+ register int p;
+ p = row_dst[x];
+ row_dst[x] = im->tpixels[im->sy - 1 - y][x];
+ row_src[x] = p;
}
}
} else {
@@ -24,44 +24,50 @@
im->tpixels[im->sy - 1 - y][x] = p;
}
}
-
}
return;
}
-BGD_DECLARE(void)
-gdImageFlipVertical(gdImagePtr im)
+BGD_DECLARE(void) gdImageFlipHorizontal(gdImagePtr im)
{
int x, y;
if (im->trueColor) {
- int p;
+ int *px1, *px2, tmp;
for (y = 0; y < im->sy; y++) {
- for (x = 0; x < im->sx / 2; x++) {
- p = im->tpixels[y][x];
- im->tpixels[y][x] = im->tpixels[y][im->sx - 1 - x];
- im->tpixels[y][im->sx - 1 - x] = p;
+ px1 = im->tpixels[y];
+ px2 = im->tpixels[y] + im->sx - 1;
+ for (x = 0; x < (im->sx >> 1); x++) {
+ tmp = *px1;
+ *px1 = *px2;
+ *px2 = tmp;
+ px1++;
+ px2--;
}
}
} else {
- unsigned char p;
+ unsigned char *px1, *px2, tmp;
for (y = 0; y < im->sy; y++) {
- for (x = 0; x < im->sx / 2; x++) {
- p = im->pixels[y][x];
- im->pixels[y][x] = im->pixels[y][im->sx - 1 - x];
- im->pixels[y][im->sx - 1 - x] = p;
+ px1 = im->pixels[y];
+ px2 = im->pixels[y] + im->sx - 1;
+ for (x = 0; x < (im->sx >> 1); x++) {
+ tmp = *px1;
+ *px1 = *px2;
+ *px2 = tmp;
+ px1++;
+ px2--;
}
}
}
}
-BGD_DECLARE(void)
-gdImageFlipBoth(gdImagePtr im)
+BGD_DECLARE(void) gdImageFlipBoth(gdImagePtr im)
{
gdImageFlipVertical(im);
gdImageFlipHorizontal(im);
}
+
http://cvs.php.net/viewvc.cgi/gd/libgd/src/gd_tga.c?r1=1.10&r2=1.11&diff_format=u
Index: gd/libgd/src/gd_tga.c
diff -u gd/libgd/src/gd_tga.c:1.10 gd/libgd/src/gd_tga.c:1.11
--- gd/libgd/src/gd_tga.c:1.10 Tue Jan 15 21:47:03 2008
+++ gd/libgd/src/gd_tga.c Wed Feb 27 23:24:59 2008
@@ -104,9 +104,9 @@
if (tga->flipv && tga->fliph) {
gdImageFlipBoth(image);
} else if (tga->flipv) {
- gdImageFlipHorizontal(image);
- } else if (tga->fliph) {
gdImageFlipVertical(image);
+ } else if (tga->fliph) {
+ gdImageFlipHorizontal(image);
}
free_tga(tga);
http://cvs.php.net/viewvc.cgi/gd/libgd/examples/CMakeLists.txt?r1=1.7&r2=1.8&diff_format=u
Index: gd/libgd/examples/CMakeLists.txt
diff -u gd/libgd/examples/CMakeLists.txt:1.7 gd/libgd/examples/CMakeLists.txt:1.8
--- gd/libgd/examples/CMakeLists.txt:1.7 Tue Jan 22 17:46:02 2008
+++ gd/libgd/examples/CMakeLists.txt Wed Feb 27 23:25:00 2008
@@ -3,10 +3,19 @@
SET(TESTS_FILES
- tgaread
+ tiffread
+ resize
+ copyrotated
+ ellipseaa
+ ellipse
+ arc
+ ellipsearc
+ flip
crop
- nnquant
- gif
+ ellfullaa
+ tgaread
+ nnquant
+ gif
)
if (WIN32)
http://cvs.php.net/viewvc.cgi/gd/libgd/examples/flip.c?view=markup&rev=1.1
Index: gd/libgd/examples/flip.c
+++ gd/libgd/examples/flip.c
/* $Id: flip.c,v 1.1 2008/02/27 23:25:00 pajoye Exp $ */
#include "gd.h"
#include <stdio.h>
#include <stdlib.h>
gdImagePtr loadImage(const char *name)
{
FILE *fp;
gdImagePtr im;
fp = fopen(name, "rb");
if (!fp) {
fprintf(stderr, "Can't open jpeg file\n");
gdImageDestroy(im);
return NULL;
}
im = gdImageCreateFromJpeg(fp);
fclose(fp);
return im;
}
int savePngImage(gdImagePtr im, const char *name)
{
FILE *fp;
fp = fopen(name, "wb");
if (!fp) {
fprintf(stderr, "Can't save png image fromtiff.png\n");
return 0;
}
gdImagePng(im, fp);
fclose(fp);
return 1;
}
int main(int argc, char **arg)
{
gdImagePtr im;
int returncode = 0;
if (argc < 2) {
fprintf(stderr, "Usage: flip [filename.png]\n");
return 1;
}
im = loadImage(arg[1]);
if (!im) goto error;
gdImageFlipHorizontal(im);
if (!savePngImage(im, "flip_horizontal.png")) {
goto error;
}
gdImageDestroy(im);
im = loadImage(arg[1]);
if (!im) goto error;
gdImageFlipVertical(im);
if (!savePngImage(im, "flip_vertical.png")) {
goto error;
}
gdImageDestroy(im);
im = loadImage(arg[1]);
if (!im) goto error;
gdImageFlipBoth(im);
if (!savePngImage(im, "flip_both.png")) {
goto error;
}
gdImageDestroy(im);
goto done;
error:
returncode = 1;
done:
return returncode;
}