[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-cvs
Subject:    [PHP-CVS] com php-src: - add image flip API support: =?UTF-8?Q?ext/gd/libgd/gd=5Ftr?= =?UTF-8?Q?ansf
From:       Pierre Joye <pajoye () php ! net>
Date:       2013-02-27 9:37:48
Message-ID: php-mail-d5f1477f4706089c66e804a1184001d087168917 () git ! php ! net
[Download RAW message or body]

Commit:    246de922e616a1843b779d312408ec288adc6fbe
Author:    Pierre Joye <pierre.php@gmail.com>         Wed, 27 Feb 2013 10:37:48 +0100
Parents:   0d65a85cc0b1c789ad70e32c97a2a82064d80a9f
Branches:  master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=246de922e616a1843b779d312408ec288adc6fbe

Log:
- add image flip API support

Changed paths:
  A  ext/gd/libgd/gd_transform.c


Diff:
diff --git a/ext/gd/libgd/gd_transform.c b/ext/gd/libgd/gd_transform.c
new file mode 100644
index 0000000..9051525
--- /dev/null
+++ b/ext/gd/libgd/gd_transform.c
@@ -0,0 +1,73 @@
+#include "gd.h"
+
+void gdImageFlipVertical(gdImagePtr im)
+{
+	register int x, y;
+
+	if (im->trueColor) {
+		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++) {
+				register int p;
+				p = row_dst[x];
+				row_dst[x] = im->tpixels[im->sy - 1 - y][x];
+				row_src[x] = p;
+			}
+		}
+	} else {
+		unsigned char p;
+		for (y = 0; y < im->sy / 2; y++) {
+			for (x = 0; x < im->sx; x++) {
+				p = im->pixels[y][x];
+				im->pixels[y][x] =	im->pixels[im->sy - 1 - y][x];
+				im->pixels[im->sy - 1 - y][x] = p;
+			}
+		}
+	}
+	return;
+}
+
+void gdImageFlipHorizontal(gdImagePtr im)
+{
+
+	int x, y;
+
+	if (im->trueColor) {
+   		int *px1, *px2, tmp;
+
+		for (y = 0; y < im->sy; y++) {
+			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 *px1, *px2, tmp;
+
+		for (y = 0; y < im->sy; y++) {
+			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--;
+			}
+		}
+	}
+}
+
+void gdImageFlipBoth(gdImagePtr im)
+{
+	gdImageFlipVertical(im);
+	gdImageFlipHorizontal(im);
+}
+
+


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic