[packages/gd] - updated to 2.1.0 (note: new soname) - updated fontpath,BoxBound,loop patches - removed obsolete ro

qboosh qboosh at pld-linux.org
Thu Jul 4 17:41:56 CEST 2013


commit 331e1f007a7794ae2ceed702b5c462cc792b6b70
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Thu Jul 4 17:41:26 2013 +0200

    - updated to 2.1.0 (note: new soname)
    - updated fontpath,BoxBound,loop patches
    - removed obsolete rotate_from_php,AALineThick,overflow,security3,format-security patches

 format-security.patch       |  36 ---
 gd-2.0.33-BoxBound.patch    |  30 +--
 gd-2.0.35-AALineThick.patch |  66 -----
 gd-2.0.35-overflow.patch    |  13 -
 gd-2.0.35-security3.patch   |  12 -
 gd-fontpath.patch           |  20 +-
 gd-loop.patch               |  39 ++-
 gd-rotate_from_php.patch    | 637 --------------------------------------------
 gd.spec                     |  52 ++--
 9 files changed, 63 insertions(+), 842 deletions(-)
---
diff --git a/gd.spec b/gd.spec
index 7cdb8d4..65f4c57 100644
--- a/gd.spec
+++ b/gd.spec
@@ -8,32 +8,33 @@ Summary(es.UTF-8):	Biblioteca para manipulación de imágenes
 Summary(pl.UTF-8):	Biblioteka do tworzenia grafiki w formacie PNG, JPEG
 Summary(pt_BR.UTF-8):	Biblioteca para manipulação de imagens
 Name:		gd
-Version:	2.0.35
-Release:	11
+Version:	2.1.0
+Release:	1
 License:	BSD-like
 Group:		Libraries
-Source0:	http://www.libgd.org/releases/%{name}-%{version}.tar.bz2
-# Source0-md5:	6c6c3dbb7bf079e0bb5fbbfd3bb8a71c
+Source0:	https://bitbucket.org/libgd/gd-libgd/downloads/libgd-%{version}.tar.xz
+# Source0-md5:	03588159bf4faab9079849c8d709acc6
 Patch0:		%{name}-fontpath.patch
-Patch1:		%{name}-rotate_from_php.patch
-Patch2:		%{name}-2.0.33-BoxBound.patch
-Patch3:		%{name}-2.0.35-AALineThick.patch
-Patch4:		%{name}-2.0.35-overflow.patch
-Patch5:		%{name}-2.0.35-security3.patch
-Patch6:		%{name}-loop.patch
-Patch7:		format-security.patch
+Patch1:		%{name}-2.0.33-BoxBound.patch
+Patch2:		%{name}-loop.patch
 URL:		http://www.libgd.org/
 BuildRequires:	autoconf >= 2.54
 BuildRequires:	automake
 %{?with_fontconfig:BuildRequires:	fontconfig-devel}
-BuildRequires:	freetype-devel >= 2.0
+BuildRequires:	freetype-devel >= 2.1.10
 BuildRequires:	gettext-devel
 BuildRequires:	libjpeg-devel
 BuildRequires:	libpng-devel >= 2:1.4.0
-BuildRequires:	libtiff-devel
-BuildRequires:	libtool >= 1:1.4.3
+BuildRequires:	libtiff-devel >= 4
+BuildRequires:	libtool >= 2:2
+BuildRequires:	libvpx-devel
+BuildRequires:	pkgconfig
+BuildRequires:	sed >= 4
+BuildRequires:	tar >= 1:1.22
 %{?with_xpm:BuildRequires:	xorg-lib-libXpm-devel}
+BuildRequires:	xz
 BuildRequires:	zlib-devel
+Requires:	freetype >= 2.1.10
 Provides:	gd(gif) = %{version}-%{release}
 # versioned by php version rotate_from_php code comes from
 Provides:	gd(imagerotate) = 5.2.0
@@ -80,9 +81,11 @@ Summary(pt_BR.UTF-8):	Arquivos de inclusão e bibliotecas para desenvolver progr
 Group:		Development/Libraries
 Requires:	%{name} = %{version}-%{release}
 Requires:	fontconfig-devel
-Requires:	freetype-devel >= 2.0
+Requires:	freetype-devel >= 2.1.10
 Requires:	libjpeg-devel
 Requires:	libpng-devel
+Requires:	libtiff-devel >= 4
+Requires:	libvpx-devel
 %{?with_xpm:Requires:	xorg-lib-libXpm-devel}
 Requires:	zlib-devel
 Provides:	gd-devel(gif) = %{version}-%{release}
@@ -146,21 +149,15 @@ Este pacote inclui vários utilitários para manipulação de arquivos gd
 para uso pelos programas que usam a libgd.
 
 %prep
-%setup -q
+%setup -q -n libgd-%{version}
 %patch0 -p1
 %patch1 -p1
 %patch2 -p1
-%patch3 -p1
-%patch4 -p1
-%patch5 -p1
-%patch6 -p1
-%patch7 -p1
 
 # hack to avoid inclusion of -s in --ldflags
-%{__perl} -pi -e 's,\@LDFLAGS\@,,g' config/gdlib-config.in
-
-# png_check_sig was replaced by png_sig_cmp in libpng
-%{__sed} -i -e 's/if (!png_check_sig (sig, 8))/if (png_sig_cmp(sig, 0, 8))/g' gd_png.c
+%{__sed} -i -e 's, at LDFLAGS@,,g' config/gdlib-config.in
+# disable error caused by subdir-objects warning in automake 1.14
+%{__sed} -i -e '/AM_INIT_AUTOMAKE/s/-Werror//' configure.ac
 
 %build
 %{__libtoolize}
@@ -187,9 +184,9 @@ rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(644,root,root,755)
-%doc COPYING index.html
+%doc COPYING ChangeLog NEWS
 %attr(755,root,root) %{_libdir}/libgd.so.*.*.*
-%attr(755,root,root) %ghost %{_libdir}/libgd.so.2
+%attr(755,root,root) %ghost %{_libdir}/libgd.so.3
 
 %files devel
 %defattr(644,root,root,755)
@@ -198,6 +195,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/libgd.la
 %{_includedir}/entities.h
 %{_includedir}/gd*.h
+%{_pkgconfigdir}/gdlib.pc
 
 %files static
 %defattr(644,root,root,755)
diff --git a/format-security.patch b/format-security.patch
deleted file mode 100644
index 64e358f..0000000
--- a/format-security.patch
+++ /dev/null
@@ -1,36 +0,0 @@
---- gd-2.0.35/gdtestft.c.orig	2012-12-12 13:17:03.460823690 +0100
-+++ gd-2.0.35/gdtestft.c	2012-12-12 13:17:31.160822713 +0100
-@@ -74,7 +74,7 @@
-     gdImageStringFT ((gdImagePtr) NULL, &brect[0], 0, f, sz, angle, 0, 0, s);
-   if (err)
-     {
--      fprintf (stderr, err);
-+      fprintf (stderr, "%s", err);
-       return 1;
-     }
- 
-@@ -146,21 +146,21 @@
-   err = gdImageStringFT (im, NULL, blue, f, sz, angle, x, y, s);
-   if (err)
-     {
--      fprintf (stderr, err);
-+      fprintf (stderr, "%s", err);
-       return 1;
-     }
-   /* Without antialiasing (negative color value) */
-   err = gdImageStringFT (im, NULL, -blue, f, sz, angle, sx + x, y, s);
-   if (err)
-     {
--      fprintf (stderr, err);
-+      fprintf (stderr, "%s", err);
-       return 1;
-     }
-   /* With antialiasing, and 50% alpha blending (truecolor only) */
-   err = gdImageStringFT (im, NULL, blueAlpha, f, sz, angle, sx * 2 + x, y, s);
-   if (err)
-     {
--      fprintf (stderr, err);
-+      fprintf (stderr, "%s", err);
-       return 1;
-     }
-   /* TBB: Write img to test/fttest.jpg or test/fttest.png */
diff --git a/gd-2.0.33-BoxBound.patch b/gd-2.0.33-BoxBound.patch
index c5daf36..7fd001d 100644
--- a/gd-2.0.33-BoxBound.patch
+++ b/gd-2.0.33-BoxBound.patch
@@ -1,22 +1,12 @@
---- gd-2.0.33/gdft.c.pom	2004-11-02 22:00:48.000000000 +0100
-+++ gd-2.0.33/gdft.c	2006-11-21 09:25:49.000000000 +0100
-@@ -1237,7 +1237,8 @@
- 	  glyph_min.x = penf.x + slot->metrics.horiBearingX;
- 	  glyph_min.y = penf.y - slot->metrics.horiBearingY;
+--- libgd-2.1.0/src/gdft.c.orig	2013-07-03 21:36:41.222081534 +0200
++++ libgd-2.1.0/src/gdft.c	2013-07-04 15:58:51.062639663 +0200
+@@ -1217,7 +1217,8 @@
+ 			glyph_min.x = penf.x + slot->metrics.horiBearingX;
+ 			glyph_min.y = penf.y - slot->metrics.horiBearingY;
  
 -#if 0
-+// #if 0 - this version of glyph_max.x setting fixes problem with 
-+//		too large bouonding box
- 	  if (ch == ' ')        /* special case for trailing space */
-             {
-               glyph_max.x = penf.x + horiAdvance;
-@@ -1246,7 +1247,8 @@
-             {
- 	      glyph_max.x = glyph_min.x + slot->metrics.width;
-             }
--#else
-+//#else
-+#if 0
-           glyph_max.x = penf.x + horiAdvance;
- #endif
- 	  glyph_max.y = glyph_min.y + slot->metrics.height;
++#if 1
++/* this version of glyph_max.x setting fixes problem with too large bounding box */
+ 			if (ch == ' ') {      /* special case for trailing space */
+ 				glyph_max.x = penf.x + horiAdvance;
+ 			} else {
diff --git a/gd-2.0.35-AALineThick.patch b/gd-2.0.35-AALineThick.patch
deleted file mode 100644
index 4349ada..0000000
--- a/gd-2.0.35-AALineThick.patch
+++ /dev/null
@@ -1,66 +0,0 @@
-diff -up gd-2.0.35/gd.c.AALineThick gd-2.0.35/gd.c
---- gd-2.0.35/gd.c.AALineThick	2007-06-19 22:25:51.000000000 +0200
-+++ gd-2.0.35/gd.c	2012-02-28 11:02:09.708015922 +0100
-@@ -3474,6 +3474,8 @@ static void gdImageAALine (gdImagePtr im
- 	/* keep them as 32bits */
- 	long x, y, inc;
- 	long dx, dy,tmp;
-+	int w, wid, wstart; 
-+	int thick = im->thick; 
- 
- 	if (!im->trueColor) {
- 		/* TBB: don't crash when the image is of the wrong type */
-@@ -3502,6 +3504,25 @@ static void gdImageAALine (gdImagePtr im
- 		gdImageSetAAPixelColor(im, x1, y1, col, 0xFF);
- 		return;
- 	}
-+	else { 
-+	    double ag; 
-+	    if (abs(dy) < abs(dx))  
-+		ag  = cos (atan2 (dy, dx)); 
-+	    else  
-+		ag = sin (atan2 (dy, dx)); 
-+	    if (ag != 0)
-+	    {
-+		wid = abs(thick / ag); 
-+	    }
-+	    else
-+	    {
-+		wid = 1;
-+	    } 
-+	    if (wid == 0)
-+	    {
-+		wid = 1;
-+	    } 
-+	} 
- 	if (abs(dx) > abs(dy)) {
- 		if (dx < 0) {
- 			tmp = x1;
-@@ -3518,8 +3539,11 @@ static void gdImageAALine (gdImagePtr im
- 		inc = (dy * 65536) / dx;
- 		/* TBB: set the last pixel for consistency (<=) */
- 		while ((x >> 16) <= x2) {
--			gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (y >> 8) & 0xFF);
--			gdImageSetAAPixelColor(im, x >> 16, (y >> 16) + 1,col, (~y >> 8) & 0xFF);
-+			wstart = (y >> 16) - wid / 2;
-+			for (w = wstart; w < wstart + wid; w++) {    
-+			    gdImageSetAAPixelColor(im, (x >> 16) , w , col , (y >> 8) & 0xFF); 
-+			    gdImageSetAAPixelColor(im, (x >> 16) , w + 1 , col, (~y >> 8) & 0xFF); 
-+			} 
- 			x += (1 << 16);
- 			y += inc;
- 		}
-@@ -3539,8 +3563,11 @@ static void gdImageAALine (gdImagePtr im
- 		inc = (dx * 65536) / dy;
- 		/* TBB: set the last pixel for consistency (<=) */
- 		while ((y>>16) <= y2) {
--			gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (x >> 8) & 0xFF);
--			gdImageSetAAPixelColor(im, (x >> 16) + 1, (y >> 16),col, (~x >> 8) & 0xFF);
-+			wstart = (x >> 16) - wid / 2;
-+			for (w = wstart; w < wstart + wid; w++) { 
-+			    gdImageSetAAPixelColor(im, w , y >> 16  , col, (x >> 8) & 0xFF);                    
-+			    gdImageSetAAPixelColor(im, w + 1, y >> 16, col, (~x >> 8) & 0xFF);   
-+			}
- 			x += inc;
- 			y += (1<<16);
- 		}
diff --git a/gd-2.0.35-overflow.patch b/gd-2.0.35-overflow.patch
deleted file mode 100644
index f71c953..0000000
--- a/gd-2.0.35-overflow.patch
+++ /dev/null
@@ -1,13 +0,0 @@
---- gd-2.0.35/gd_gd.c.pom	2006-04-05 17:52:22.000000000 +0200
-+++ gd-2.0.35/gd_gd.c	2007-09-05 11:31:39.000000000 +0200
-@@ -149,6 +149,10 @@ _gdCreateFromFile (gdIOCtx * in, int *sx
-     {
-       im = gdImageCreate (*sx, *sy);
-     }
-+  if (!im) 
-+    { 
-+      goto fail1; 
-+    } 
-   if (!_gdGetColors (in, im, gd2xFlag))
-     {
-       goto fail2;
diff --git a/gd-2.0.35-security3.patch b/gd-2.0.35-security3.patch
deleted file mode 100644
index e15587b..0000000
--- a/gd-2.0.35-security3.patch
+++ /dev/null
@@ -1,12 +0,0 @@
---- gd-2.0.28/gd_gd.c	2004-05-24 17:28:12.000000000 +0200
-+++ gd-2.0.28_new/gd_gd.c	2009-12-08 15:19:16.159836680 +0100
-@@ -44,6 +44,9 @@
- 	    {
- 	      goto fail1;
- 	    }
-+	    if (im->colorsTotal > gdMaxColors) {
-+	      goto fail1;
-+		}
- 	}
-       /* Int to accommodate truecolor single-color transparency */
-       if (!gdGetInt (&im->transparent, in))
diff --git a/gd-fontpath.patch b/gd-fontpath.patch
index 8f836ed..eeac0e3 100644
--- a/gd-fontpath.patch
+++ b/gd-fontpath.patch
@@ -1,11 +1,11 @@
---- gd-2.0.23/gd.h.orig	2004-04-21 23:19:49.000000000 +0200
-+++ gd-2.0.23/gd.h	2004-04-21 23:24:10.433748224 +0200
-@@ -40,7 +40,7 @@
- /* 2.0.23: more Type 1 fonts */
- #ifndef DEFAULT_FONTPATH
- /* default fontpath for unix systems  - whatever happened to standards ! */
--#define DEFAULT_FONTPATH "/usr/X11R6/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/truetype:/usr/X11R6/lib/X11/fonts/TTF:/usr/share/fonts/TrueType:/usr/share/fonts/truetype:/usr/openwin/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/Type1:/usr/lib/X11/fonts/Type1:/usr/openwin/lib/X11/fonts/Type1"
-+#define DEFAULT_FONTPATH "/usr/share/fonts/TTF:/usr/share/fonts/Type1"
+--- libgd-2.1.0/src/gdft.c.orig	2013-06-25 11:58:23.000000000 +0200
++++ libgd-2.1.0/src/gdft.c	2013-07-03 21:32:22.648759053 +0200
+@@ -74,7 +74,7 @@
+ #    define DEFAULT_FONTPATH "/usr/share/fonts/truetype:/System/Library/Fonts:/Library/Fonts"
+ #  else
+    /* default fontpath for unix systems  - whatever happened to standards ! */
+-#    define DEFAULT_FONTPATH "/usr/X11R6/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/truetype:/usr/X11R6/lib/X11/fonts/TTF:/usr/share/fonts/TrueType:/usr/share/fonts/truetype:/usr/openwin/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/Type1:/usr/lib/X11/fonts/Type1:/usr/openwin/lib/X11/fonts/Type1"
++#    define DEFAULT_FONTPATH "/usr/share/fonts/TTF:/usr/share/fonts/Type1"
+ #  endif
  #endif
- #ifndef PATHSEPARATOR
- #define PATHSEPARATOR ":"
+ 
diff --git a/gd-loop.patch b/gd-loop.patch
index 9d08965..50fc71a 100644
--- a/gd-loop.patch
+++ b/gd-loop.patch
@@ -1,24 +1,21 @@
-diff -up gd-2.0.35/gd_gif_in.c.loop gd-2.0.35/gd_gif_in.c
---- gd-2.0.35/gd_gif_in.c.loop	2007-06-14 15:51:41.000000000 -0400
-+++ gd-2.0.35/gd_gif_in.c	2008-07-21 11:20:25.000000000 -0400
-@@ -453,16 +453,17 @@ LWZReadByte_(gdIOCtx *fd, LZW_STATIC_DAT
-                        return sd->firstcode;
-                } else if (code == sd->end_code) {
-                        int             count;
-+                       int             max_count = 1024;
-                        unsigned char   buf[260];
+--- libgd-2.1.0/src/gd_gif_in.c.orig	2013-07-04 16:17:44.855925413 +0200
++++ libgd-2.1.0/src/gd_gif_in.c	2013-07-04 16:35:04.025881804 +0200
+@@ -498,15 +498,16 @@ LWZReadByte_(gdIOCtx *fd, LZW_STATIC_DAT
+ 			return sd->firstcode;
+ 		} else if(code == sd->end_code) {
+ 			int count;
++			int max_count = 1024;
+ 			unsigned char buf[260];
  
-                        if (*ZeroDataBlockP)
-                                return -2;
+ 			if(*ZeroDataBlockP) {
+ 				return -2;
+ 			}
  
--                       while ((count = GetDataBlock(fd, buf, ZeroDataBlockP)) > 0)
-+                       while ((count = GetDataBlock(fd, buf, ZeroDataBlockP)) > 0 && --max_count >= 0 )
-                                ;
+-			while((count = GetDataBlock(fd, buf, ZeroDataBlockP)) > 0);
++			while((count = GetDataBlock(fd, buf, ZeroDataBlockP)) > 0 && (--max_count >= 0));
  
--                       if (count != 0)
--                       return -2;
-+                       if (count != 0 || max_count < 0 )
-+                               return -2;
-                }
- 
-                incode = code;
+-			if(count != 0) {
++			if((count != 0) || (max_count < 0)) {
+ 				return -2;
+ 			}
+ 		}
diff --git a/gd-rotate_from_php.patch b/gd-rotate_from_php.patch
deleted file mode 100644
index 0bde9aa..0000000
--- a/gd-rotate_from_php.patch
+++ /dev/null
@@ -1,637 +0,0 @@
---- gd-2.0.33/gd.c.orig	2006-12-23 02:27:25.723423857 +0100
-+++ gd-2.0.33/gd.c	2006-12-23 02:31:59.599031139 +0100
-@@ -65,6 +65,10 @@
- 
- static void gdImageBrushApply (gdImagePtr im, int x, int y);
- static void gdImageTileApply (gdImagePtr im, int x, int y);
-+/* from php */
-+static int gdLayerOverlay(int dst, int src);
-+static int gdAlphaOverlayColor(int src, int dst, int max);
-+/* end from php */
- BGD_DECLARE(int) gdImageGetTrueColorPixel (gdImagePtr im, int x, int y);
- 
- BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy)
-@@ -761,16 +765,22 @@
-     default:
-       if (gdImageBoundsSafeMacro (im, x, y))
- 	{
--	  if (im->trueColor)
--	    {
--	      if (im->alphaBlendingFlag)
--		{
--		  im->tpixels[y][x] = gdAlphaBlend (im->tpixels[y][x], color);
--		}
--	      else
--		{
--		  im->tpixels[y][x] = color;
--		}
-+	  if (im->trueColor) {
-+		      switch (im->alphaBlendingFlag) {
-+			      default:
-+			      case gdEffectReplace:
-+				      im->tpixels[y][x] = color;
-+				      break;
-+			      case gdEffectAlphaBlend:
-+				      im->tpixels[y][x] = gdAlphaBlend(im->tpixels[y][x], color);
-+				      break;
-+			      case gdEffectNormal:
-+				      im->tpixels[y][x] = gdAlphaBlend(im->tpixels[y][x], color);
-+				      break;
-+			      case gdEffectOverlay :
-+				      im->tpixels[y][x] = gdLayerOverlay(im->tpixels[y][x], color);
-+				      break;
-+		      }
- 	    }
- 	  else
- 	    {
-@@ -2287,6 +2297,564 @@
-     }
- }
- 
-+/* Taken from php */
-+/*
-+ * Rotate function Added on 2003/12
-+ * by Pierre-Alain Joye (pajoye at pearfr.org)
-+ **/
-+/* Begin rotate function */
-+#ifdef ROTATE_PI
-+#undef ROTATE_PI
-+#endif /* ROTATE_PI */
-+
-+#define ROTATE_DEG2RAD  3.1415926535897932384626433832795/180
-+BGD_DECLARE(void) gdImageSkewX (gdImagePtr dst, gdImagePtr src, int uRow, int iOffset, double dWeight, int clrBack, int ignoretransparent)
-+{
-+	typedef int (*FuncPtr)(gdImagePtr, int, int);
-+	int i, r, g, b, a, clrBackR, clrBackG, clrBackB, clrBackA;
-+	FuncPtr f;
-+
-+	int pxlOldLeft, pxlLeft=0, pxlSrc;
-+
-+	/* Keep clrBack as color index if required */
-+	if (src->trueColor) {
-+		pxlOldLeft = clrBack;
-+		f = gdImageGetTrueColorPixel;
-+	} else {
-+		pxlOldLeft = clrBack;
-+		clrBackR = gdImageRed(src, clrBack);
-+		clrBackG = gdImageGreen(src, clrBack);
-+		clrBackB = gdImageBlue(src, clrBack);
-+		clrBackA = gdImageAlpha(src, clrBack);
-+		clrBack =  gdTrueColorAlpha(clrBackR, clrBackG, clrBackB, clrBackA);
-+		f = gdImageGetPixel;
-+	}
-+
-+	for (i = 0; i < iOffset; i++) {
-+		gdImageSetPixel (dst, i, uRow, clrBack);
-+	}
-+
-+	if (i < dst->sx) {
-+		gdImageSetPixel (dst, i, uRow, clrBack);
-+	}
-+
-+	for (i = 0; i < src->sx; i++) {
-+		pxlSrc = f (src,i,uRow);
-+
-+		r = (int)(gdImageRed(src,pxlSrc) * dWeight);
-+		g = (int)(gdImageGreen(src,pxlSrc) * dWeight);
-+		b = (int)(gdImageBlue(src,pxlSrc) * dWeight);
-+		a = (int)(gdImageAlpha(src,pxlSrc) * dWeight);
-+
-+		pxlLeft = gdImageColorAllocateAlpha(src, r, g, b, a);
-+
-+		if (pxlLeft == -1) {
-+			pxlLeft = gdImageColorClosestAlpha(src, r, g, b, a);
-+		}
-+
-+		r = gdImageRed(src,pxlSrc) - (gdImageRed(src,pxlLeft) - gdImageRed(src,pxlOldLeft));
-+		g = gdImageGreen(src,pxlSrc) - (gdImageGreen(src,pxlLeft) - gdImageGreen(src,pxlOldLeft));
-+		b = gdImageBlue(src,pxlSrc) - (gdImageBlue(src,pxlLeft) - gdImageBlue(src,pxlOldLeft));
-+		a = gdImageAlpha(src,pxlSrc) - (gdImageAlpha(src,pxlLeft) - gdImageAlpha(src,pxlOldLeft));
-+
-+		if (r>255) {
-+			r = 255;
-+		}
-+
-+		if (g>255) {
-+			g = 255;
-+		}
-+
-+		if (b>255) {
-+			b = 255;
-+		}
-+
-+		if (a>127) {
-+			a = 127;
-+		}
-+
-+		if (ignoretransparent && pxlSrc == dst->transparent) {
-+			pxlSrc = dst->transparent;
-+		} else {
-+			pxlSrc = gdImageColorAllocateAlpha(dst, r, g, b, a);
-+
-+			if (pxlSrc == -1) {
-+				pxlSrc = gdImageColorClosestAlpha(dst, r, g, b, a);
-+			}
-+		}
-+
-+		if ((i + iOffset >= 0) && (i + iOffset < dst->sx)) {
-+			gdImageSetPixel (dst, i+iOffset, uRow,  pxlSrc);
-+		}
-+
-+		pxlOldLeft = pxlLeft;
-+	}
-+
-+	i += iOffset;
-+
-+	if (i < dst->sx) {
-+		gdImageSetPixel (dst, i, uRow, pxlLeft);
-+	}
-+
-+	gdImageSetPixel (dst, iOffset, uRow, clrBack);
-+
-+	i--;
-+
-+	while (++i < dst->sx) {
-+		gdImageSetPixel (dst, i, uRow, clrBack);
-+	}
-+}
-+
-+void gdImageSkewY (gdImagePtr dst, gdImagePtr src, int uCol, int iOffset, double dWeight, int clrBack, int ignoretransparent)
-+{
-+	typedef int (*FuncPtr)(gdImagePtr, int, int);
-+	int i, iYPos=0, r, g, b, a;
-+	FuncPtr f;
-+	int pxlOldLeft, pxlLeft=0, pxlSrc;
-+
-+	if (src->trueColor) {
-+		f = gdImageGetTrueColorPixel;
-+	} else {
-+		f = gdImageGetPixel;
-+	}
-+
-+	for (i = 0; i<=iOffset; i++) {
-+		gdImageSetPixel (dst, uCol, i, clrBack);
-+	}
-+	r = (int)((double)gdImageRed(src,clrBack) * dWeight);
-+	g = (int)((double)gdImageGreen(src,clrBack) * dWeight);
-+	b = (int)((double)gdImageBlue(src,clrBack) * dWeight);
-+	a = (int)((double)gdImageAlpha(src,clrBack) * dWeight);
-+
-+	pxlOldLeft = gdImageColorAllocateAlpha(dst, r, g, b, a);
-+
-+	for (i = 0; i < src->sy; i++) {
-+		pxlSrc = f (src, uCol, i);
-+		iYPos = i + iOffset;
-+
-+		r = (int)((double)gdImageRed(src,pxlSrc) * dWeight);
-+		g = (int)((double)gdImageGreen(src,pxlSrc) * dWeight);
-+		b = (int)((double)gdImageBlue(src,pxlSrc) * dWeight);
-+		a = (int)((double)gdImageAlpha(src,pxlSrc) * dWeight);
-+
-+		pxlLeft = gdImageColorAllocateAlpha(src, r, g, b, a);
-+
-+		if (pxlLeft == -1) {
-+			pxlLeft = gdImageColorClosestAlpha(src, r, g, b, a);
-+		}
-+
-+		r = gdImageRed(src,pxlSrc) - (gdImageRed(src,pxlLeft) - gdImageRed(src,pxlOldLeft));
-+		g = gdImageGreen(src,pxlSrc) - (gdImageGreen(src,pxlLeft) - gdImageGreen(src,pxlOldLeft));
-+		b = gdImageBlue(src,pxlSrc) - (gdImageBlue(src,pxlLeft) - gdImageBlue(src,pxlOldLeft));
-+		a = gdImageAlpha(src,pxlSrc) - (gdImageAlpha(src,pxlLeft) - gdImageAlpha(src,pxlOldLeft));
-+
-+		if (r>255) {
-+			r = 255;
-+		}
-+
-+		if (g>255) {
-+			g = 255;
-+		}
-+
-+		if (b>255) {
-+			b = 255;
-+		}
-+
-+		if (a>127) {
-+			a = 127;
-+		}
-+
-+		if (ignoretransparent && pxlSrc == dst->transparent) {
-+			pxlSrc = dst->transparent;
-+		} else {
-+			pxlSrc = gdImageColorAllocateAlpha(dst, r, g, b, a);
-+
-+			if (pxlSrc == -1) {
-+				pxlSrc = gdImageColorClosestAlpha(dst, r, g, b, a);
-+			}
-+		}
-+
-+		if ((iYPos >= 0) && (iYPos < dst->sy)) {
-+			gdImageSetPixel (dst, uCol, iYPos, pxlSrc);
-+		}
-+
-+		pxlOldLeft = pxlLeft;
-+	}
-+
-+	i = iYPos;
-+	if (i < dst->sy) {
-+		gdImageSetPixel (dst, uCol, i, pxlLeft);
-+	}
-+
-+	i--;
-+	while (++i < dst->sy) {
-+		gdImageSetPixel (dst, uCol, i, clrBack);
-+	}
-+}
-+
-+/* Rotates an image by 90 degrees (counter clockwise) */
-+BGD_DECLARE(gdImagePtr) gdImageRotate90 (gdImagePtr src, int ignoretransparent)
-+{
-+	int uY, uX;
-+	int c,r,g,b,a;
-+	gdImagePtr dst;
-+	typedef int (*FuncPtr)(gdImagePtr, int, int);
-+	FuncPtr f;
-+
-+	if (src->trueColor) {
-+		f = gdImageGetTrueColorPixel;
-+	} else {
-+		f = gdImageGetPixel;
-+	}
-+	dst = gdImageCreateTrueColor(src->sy, src->sx);
-+	dst->transparent = src->transparent;
-+
-+	if (dst != NULL) {
-+		gdImagePaletteCopy (dst, src);
-+
-+		for (uY = 0; uY<src->sy; uY++) {
-+			for (uX = 0; uX<src->sx; uX++) {
-+				c = f (src, uX, uY);
-+				if (!src->trueColor) {
-+					r = gdImageRed(src,c);
-+					g = gdImageGreen(src,c);
-+					b = gdImageBlue(src,c);
-+					a = gdImageAlpha(src,c);
-+					c = gdTrueColorAlpha(r, g, b, a);
-+				}
-+				if (ignoretransparent && c == dst->transparent) {
-+					gdImageSetPixel(dst, uY, (dst->sy - uX - 1), dst->transparent);
-+				} else {
-+					gdImageSetPixel(dst, uY, (dst->sy - uX - 1), c);
-+				}
-+			}
-+		}
-+	}
-+
-+	return dst;
-+}
-+
-+/* Rotates an image by 180 degrees (counter clockwise) */
-+BGD_DECLARE(gdImagePtr) gdImageRotate180 (gdImagePtr src, int ignoretransparent)
-+{
-+	int uY, uX;
-+	int c,r,g,b,a;
-+	gdImagePtr dst;
-+	typedef int (*FuncPtr)(gdImagePtr, int, int);
-+	FuncPtr f;
-+
-+	if (src->trueColor) {
-+		f = gdImageGetTrueColorPixel;
-+	} else {
-+		f = gdImageGetPixel;
-+	}
-+	dst = gdImageCreateTrueColor(src->sx, src->sy);
-+	dst->transparent = src->transparent;
-+
-+	if (dst != NULL) {
-+		gdImagePaletteCopy (dst, src);
-+
-+		for (uY = 0; uY<src->sy; uY++) {
-+			for (uX = 0; uX<src->sx; uX++) {
-+				c = f (src, uX, uY);
-+				if (!src->trueColor) {
-+					r = gdImageRed(src,c);
-+					g = gdImageGreen(src,c);
-+					b = gdImageBlue(src,c);
-+					a = gdImageAlpha(src,c);
-+					c = gdTrueColorAlpha(r, g, b, a);
-+				}
-+
-+				if (ignoretransparent && c == dst->transparent) {
-+					gdImageSetPixel(dst, (dst->sx - uX - 1), (dst->sy - uY - 1), dst->transparent);
-+				} else {
-+					gdImageSetPixel(dst, (dst->sx - uX - 1), (dst->sy - uY - 1), c);
-+				}
-+			}
-+		}
-+	}
-+
-+	return dst;
-+}
-+
-+/* Rotates an image by 270 degrees (counter clockwise) */
-+BGD_DECLARE(gdImagePtr) gdImageRotate270 (gdImagePtr src, int ignoretransparent)
-+{
-+	int uY, uX;
-+	int c,r,g,b,a;
-+	gdImagePtr dst;
-+	typedef int (*FuncPtr)(gdImagePtr, int, int);
-+	FuncPtr f;
-+
-+	if (src->trueColor) {
-+		f = gdImageGetTrueColorPixel;
-+	} else {
-+		f = gdImageGetPixel;
-+	}
-+	dst = gdImageCreateTrueColor (src->sy, src->sx);
-+	dst->transparent = src->transparent;
-+
-+	if (dst != NULL) {
-+		gdImagePaletteCopy (dst, src);
-+
-+		for (uY = 0; uY<src->sy; uY++) {
-+			for (uX = 0; uX<src->sx; uX++) {
-+				c = f (src, uX, uY);
-+				if (!src->trueColor) {
-+					r = gdImageRed(src,c);
-+					g = gdImageGreen(src,c);
-+					b = gdImageBlue(src,c);
-+					a = gdImageAlpha(src,c);
-+					c = gdTrueColorAlpha(r, g, b, a);
-+				}
-+
-+				if (ignoretransparent && c == dst->transparent) {
-+					gdImageSetPixel(dst, (dst->sx - uY - 1), uX, dst->transparent);
-+				} else {
-+					gdImageSetPixel(dst, (dst->sx - uY - 1), uX, c);
-+				}
-+			}
-+		}
-+	}
-+
-+	return dst;
-+}
-+
-+BGD_DECLARE(gdImagePtr) gdImageRotate45 (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent)
-+{
-+	typedef int (*FuncPtr)(gdImagePtr, int, int);
-+	gdImagePtr dst1,dst2,dst3;
-+	FuncPtr f;
-+	double dRadAngle, dSinE, dTan, dShear;
-+	double dOffset;     /* Variable skew offset */
-+	int u, iShear, newx, newy;
-+	int clrBackR, clrBackG, clrBackB, clrBackA;
-+
-+	/* See GEMS I for the algorithm details */
-+	dRadAngle = dAngle * ROTATE_DEG2RAD; /* Angle in radians */
-+	dSinE = sin (dRadAngle);
-+	dTan = tan (dRadAngle / 2.0);
-+
-+	newx = (int)(src->sx + src->sy * fabs(dTan));
-+	newy = src->sy;
-+
-+	/* 1st shear */
-+	if (src->trueColor) {
-+		f = gdImageGetTrueColorPixel;
-+	} else {
-+		f = gdImageGetPixel;
-+	}
-+
-+	dst1 = gdImageCreateTrueColor(newx, newy);
-+	/******* Perform 1st shear (horizontal) ******/
-+	if (dst1 == NULL) {
-+		return NULL;
-+	}
-+	dst1->alphaBlendingFlag = gdEffectReplace;
-+
-+	if (dAngle == 0.0) {
-+		/* Returns copy of src */
-+		gdImageCopy (dst1, src,0,0,0,0,src->sx,src->sy);
-+		return dst1;
-+	}
-+
-+	gdImagePaletteCopy (dst1, src);
-+
-+	if (ignoretransparent) {
-+		if (gdImageTrueColor(src)) {
-+			dst1->transparent = src->transparent;
-+		} else {
-+
-+			dst1->transparent = gdTrueColorAlpha(gdImageRed(src, src->transparent), gdImageBlue(src, src->transparent), gdImageGreen(src, src->transparent), 127);
-+		}
-+	}
-+
-+	dRadAngle = dAngle * ROTATE_DEG2RAD; /* Angle in radians */
-+	dSinE = sin (dRadAngle);
-+	dTan = tan (dRadAngle / 2.0);
-+
-+	for (u = 0; u < dst1->sy; u++) {
-+		if (dTan >= 0.0) {
-+			dShear = ((double)(u + 0.5)) * dTan;
-+		} else {
-+			dShear = ((double)(u - dst1->sy) + 0.5) * dTan;
-+		}
-+
-+		iShear = (int)floor(dShear);
-+		gdImageSkewX(dst1, src, u, iShear, (dShear - iShear), clrBack, ignoretransparent);
-+	}
-+
-+	/*
-+	The 1st shear may use the original clrBack as color index
-+	Convert it once here
-+	*/
-+	if(!src->trueColor) {
-+		clrBackR = gdImageRed(src, clrBack);
-+		clrBackG = gdImageGreen(src, clrBack);
-+		clrBackB = gdImageBlue(src, clrBack);
-+		clrBackA = gdImageAlpha(src, clrBack);
-+		clrBack =  gdTrueColorAlpha(clrBackR, clrBackG, clrBackB, clrBackA);
-+	}
-+	/* 2nd shear */
-+	newx = dst1->sx;
-+
-+	if (dSinE > 0.0) {
-+		dOffset = (src->sx-1) * dSinE;
-+	} else {
-+		dOffset = -dSinE *  (src->sx - newx);
-+	}
-+
-+	newy = (int) ((double) src->sx * fabs( dSinE ) + (double) src->sy * cos (dRadAngle))+1;
-+
-+	if (src->trueColor) {
-+		f = gdImageGetTrueColorPixel;
-+	} else {
-+		f = gdImageGetPixel;
-+	}
-+	dst2 = gdImageCreateTrueColor(newx, newy);
-+	if (dst2 == NULL) {
-+		gdImageDestroy(dst1);
-+		return NULL;
-+	}
-+	dst2->alphaBlendingFlag = gdEffectReplace;
-+	if (ignoretransparent) {
-+		dst2->transparent = dst1->transparent;
-+	}
-+
-+	for (u = 0; u < dst2->sx; u++, dOffset -= dSinE) {
-+		iShear = (int)floor (dOffset);
-+		gdImageSkewY(dst2, dst1, u, iShear, (dOffset - (double)iShear), clrBack, ignoretransparent);
-+	}
-+
-+	/* 3rd shear */
-+	gdImageDestroy(dst1);
-+
-+	newx = (int) ((double)src->sy * fabs (dSinE) + (double)src->sx * cos (dRadAngle)) + 1;
-+	newy = dst2->sy;
-+
-+	if (src->trueColor) {
-+		f = gdImageGetTrueColorPixel;
-+	} else {
-+		f = gdImageGetPixel;
-+	}
-+	dst3 = gdImageCreateTrueColor(newx, newy);
-+	if (dst3 == NULL) {
-+		gdImageDestroy(dst2);
-+		return NULL;
-+	}
-+
-+	dst3->alphaBlendingFlag = gdEffectReplace;
-+	if (ignoretransparent) {
-+		dst3->transparent = dst2->transparent;
-+	}
-+
-+	if (dSinE >= 0.0) {
-+		dOffset = (double)(src->sx - 1) * dSinE * -dTan;
-+	} else {
-+		dOffset = dTan * ((double)(src->sx - 1) * -dSinE + (double)(1 - newy));
-+	}
-+
-+	for (u = 0; u < dst3->sy; u++, dOffset += dTan) {
-+		int iShear = (int)floor(dOffset);
-+		gdImageSkewX(dst3, dst2, u, iShear, (dOffset - iShear), clrBack, ignoretransparent);
-+	}
-+
-+	gdImageDestroy(dst2);
-+
-+	return dst3;
-+}
-+
-+BGD_DECLARE(gdImagePtr) gdImageRotate (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent)
-+{
-+	gdImagePtr pMidImg;
-+	gdImagePtr rotatedImg;
-+
-+	if (src == NULL) {
-+		return NULL;
-+	}
-+
-+	if (!gdImageTrueColor(src) && clrBack>=gdImageColorsTotal(src)) {
-+		return NULL;
-+	}
-+
-+	while (dAngle >= 360.0) {
-+		dAngle -= 360.0;
-+	}
-+
-+	while (dAngle < 0) {
-+		dAngle += 360.0;
-+	}
-+
-+	if (dAngle == 90.00) {
-+		return gdImageRotate90(src, ignoretransparent);
-+	}
-+	if (dAngle == 180.00) {
-+		return gdImageRotate180(src, ignoretransparent);
-+	}
-+	if(dAngle == 270.00) {
-+		return gdImageRotate270 (src, ignoretransparent);
-+	}
-+
-+	if ((dAngle > 45.0) && (dAngle <= 135.0)) {
-+		pMidImg = gdImageRotate90 (src, ignoretransparent);
-+		dAngle -= 90.0;
-+	} else if ((dAngle > 135.0) && (dAngle <= 225.0)) {
-+		pMidImg = gdImageRotate180 (src, ignoretransparent);
-+		dAngle -= 180.0;
-+	} else if ((dAngle > 225.0) && (dAngle <= 315.0)) {
-+		pMidImg = gdImageRotate270 (src, ignoretransparent);
-+		dAngle -= 270.0;
-+	} else {
-+		return gdImageRotate45 (src, dAngle, clrBack, ignoretransparent);
-+	}
-+
-+	if (pMidImg == NULL) {
-+		return NULL;
-+	}
-+
-+	rotatedImg = gdImageRotate45 (pMidImg, dAngle, clrBack, ignoretransparent);
-+	gdImageDestroy(pMidImg);
-+
-+	return rotatedImg;
-+}
-+/* End Rotate function */
-+
-+static int gdLayerOverlay (int dst, int src)
-+{
-+	int a1, a2;
-+	a1 = gdAlphaMax - gdTrueColorGetAlpha(dst);
-+	a2 = gdAlphaMax - gdTrueColorGetAlpha(src);
-+	return ( ((gdAlphaMax - a1*a2/gdAlphaMax) << 24) +
-+		(gdAlphaOverlayColor( gdTrueColorGetRed(src), gdTrueColorGetRed(dst), gdRedMax ) << 16) +
-+		(gdAlphaOverlayColor( gdTrueColorGetGreen(src), gdTrueColorGetGreen(dst), gdGreenMax ) << 8) +
-+		(gdAlphaOverlayColor( gdTrueColorGetBlue(src), gdTrueColorGetBlue(dst), gdBlueMax ))
-+		);
-+}
-+
-+static int gdAlphaOverlayColor (int src, int dst, int max )
-+{
-+	/* this function implements the algorithm
-+	 *
-+	 * for dst[rgb] < 0.5,
-+	 *   c[rgb] = 2.src[rgb].dst[rgb]
-+	 * and for dst[rgb] > 0.5,
-+	 *   c[rgb] = -2.src[rgb].dst[rgb] + 2.dst[rgb] + 2.src[rgb] - 1
-+	 *
-+	 */
-+
-+	dst = dst << 1;
-+	if( dst > max ) {
-+		/* in the "light" zone */
-+		return dst + (src << 1) - (dst * src / max) - max;
-+	} else {
-+		/* in the "dark" zone */
-+		return dst * src / max;
-+	}
-+}
-+
-+
-+/* End of part code from php */
-+
- /* When gd 1.x was first created, floating point was to be avoided.
-    These days it is often faster than table lookups or integer
-    arithmetic. The routine below is shamelessly, gloriously
---- gd-2.0.33/gd.h.orig	2006-12-23 01:06:10.281588261 +0100
-+++ gd-2.0.33/gd.h	2006-12-23 01:48:20.989805102 +0100
-@@ -117,6 +117,10 @@
- #define gdTrueColorGetRed(c) (((c) & 0xFF0000) >> 16)
- #define gdTrueColorGetGreen(c) (((c) & 0x00FF00) >> 8)
- #define gdTrueColorGetBlue(c) ((c) & 0x0000FF)
-+#define gdEffectReplace 0
-+#define gdEffectAlphaBlend 1
-+#define gdEffectNormal 2
-+#define gdEffectOverlay 3
- 
- /* This function accepts truecolor pixel values only. The 
- 	source color is composited with the destination color
-@@ -691,6 +695,12 @@
- 			   int srcX, int srcY,
- 			   int srcWidth, int srcHeight, int angle);
- 
-+gdImagePtr gdImageRotate90(gdImagePtr src, int ignoretransparent);
-+gdImagePtr gdImageRotate180(gdImagePtr src, int ignoretransparent);
-+gdImagePtr gdImageRotate270(gdImagePtr src, int ignoretransparent);
-+gdImagePtr gdImageRotate45(gdImagePtr src, double dAngle, int clrBack, int ignoretransparent);
-+gdImagePtr gdImageRotate (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent);
-+
- BGD_DECLARE(void) gdImageSetBrush (gdImagePtr im, gdImagePtr brush);
- BGD_DECLARE(void) gdImageSetTile (gdImagePtr im, gdImagePtr tile);
- BGD_DECLARE(void) gdImageSetAntiAliased (gdImagePtr im, int c);
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/gd.git/commitdiff/331e1f007a7794ae2ceed702b5c462cc792b6b70



More information about the pld-cvs-commit mailing list