Commits

Anonymous committed 141b386

- #129, Add flip functions, horizontally, vertically

Comments (0)

Files changed (3)

src/CMakeLists.txt

 SET (LIBGD_SRC_FILES
 	gd.c
 	gdfx.c
+	gd_transform.c
 	gd_security.c
 	gd_gd.c
 	gd_gd2.c
 
 lib_LTLIBRARIES = libgd.la
 
-libgd_la_SOURCES = gd.c gdfx.c gd_security.c gd_gd.c gd_gd2.c gd_io.c gd_io_dp.c gd_gif_in.c gd_gif_out.c gd_io_file.c gd_io_ss.c gd_jpeg.c gd_png.c gd_ss.c gd_topal.c gd_wbmp.c gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c gdft.c gdhelpers.c gdhelpers.h gdkanji.c gdtables.c gdxpm.c jisx0208.h wbmp.c wbmp.h
+libgd_la_SOURCES = gd.c gd_transform.c gdfx.c gd_security.c gd_gd.c gd_gd2.c gd_io.c gd_io_dp.c gd_gif_in.c gd_gif_out.c gd_io_file.c gd_io_ss.c gd_jpeg.c gd_png.c gd_ss.c gd_topal.c gd_wbmp.c gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c gdft.c gdhelpers.c gdhelpers.h gdkanji.c gdtables.c gdxpm.c jisx0208.h wbmp.c wbmp.h
 
 libgd_la_LDFLAGS = -version-info 2:0:0 $(XTRA_LDFLAGS)
 

src/gd_transform.c

+#include "gd.h"
+
+BGD_DECLARE(int)
+gdImageFlipHorizontal(gdImagePtr im)
+{
+	int *p1, *p2, *src;
+	register int x, y, tmp;
+
+
+	if (im->trueColor) {
+		int p;
+		for (y = 0; y < im->sy / 2; 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;
+			}
+		}
+	} else {
+		unsigned char p;
+		for (y = 0; y < im->sy / 2; 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;
+			}
+		}
+
+	}
+	return 1;
+}
+
+BGD_DECLARE(int)
+gdImageFlipVertical(gdImagePtr im)
+{
+
+	int x, y;
+	int w = im->sx;
+	int h = im->sy;
+
+	if (im->trueColor) {
+		int p;
+
+		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;
+			}
+		}
+	} else {
+		unsigned char p;
+
+		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;
+			}
+		}
+	}
+}
+
+BGD_DECLARE(int)
+gdImageFlipBoth(gdImagePtr im)
+{
+	int res;
+
+	res = gdImageFlipVertical(im);
+	res &= gdImageFlipHorizontal(im);
+	return res;
+}
+