- sync to 2.0.8
parent
31dcc29500
commit
21da27e012
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
AC_PREREQ(2.54)
|
||||
|
||||
AC_INIT([GD], [2.0.7], [gd@boutell.com])
|
||||
AC_INIT([GD], [2.0.8], [gd@boutell.com])
|
||||
AC_CONFIG_SRCDIR([gd.c])
|
||||
AC_CONFIG_AUX_DIR(config)
|
||||
|
||||
|
@ -69,11 +69,12 @@ if test "$withval" != no; then
|
|||
if test -n "$LIBPNG_CONFIG"; then
|
||||
libpng_CPPFLAGS=`libpng-config --cflags`
|
||||
# should be --ldopts, but it's currently broken
|
||||
libpng_LDFLAGS=`libpng-config --ldflags | sed 's/ *-l.*$//'`
|
||||
libpng_LDFLAGS=`libpng-config --ldflags | sed 's/-l[[^ ]][[^ ]]*//g'`
|
||||
elif test -d "$withval"; then
|
||||
libpng_CPPFLAGS="-I$withval/include"
|
||||
libpng_LDFLAGS="-L$withval/lib"
|
||||
fi
|
||||
|
||||
_cppflags="$CPPFLAGS"
|
||||
_ldflags="$LDFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $libpng_CPPFLAGS"
|
||||
|
@ -112,18 +113,18 @@ if test "$withval" != no; then
|
|||
if test -n "$FREETYPE_CONFIG"; then
|
||||
if test -n "$FREETYPE_DIR"; then
|
||||
libft_INCLUDES="`$FREETYPE_CONFIG --cflags` -I$FREETYPE_DIR/include"
|
||||
libft_LDFLAGS=`$FREETYPE_CONFIG --libs`
|
||||
libft_LDFLAGS=`$FREETYPE_CONFIG --libs |sed 's/-l[[^ ]][[^ ]]*//g'`
|
||||
else
|
||||
libft_INCLUDES=`$FREETYPE_CONFIG --cflags`
|
||||
libft_LDFLAGS=`$FREETYPE_CONFIG --libs`
|
||||
libft_LDFLAGS=`$FREETYPE_CONFIG --libs |sed 's/-l[[^ ]][[^ ]]*//g'`
|
||||
fi
|
||||
else
|
||||
if test -n "$FREETYPE_DIR"; then
|
||||
libft_INCLUDES="-I$FREETYPE_DIR/include/freetype2 -I$FREETYPE_DIR/include"
|
||||
libft_LDFLAGS="-L$FREETYPE_DIR/lib -lfreetype"
|
||||
libft_LDFLAGS="-L$FREETYPE_DIR/lib"
|
||||
else
|
||||
libft_INCLUDES=""
|
||||
libft_LDFLAGS="-lfreetype"
|
||||
libft_LDFLAGS=""
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
72
src/gd.c
72
src/gd.c
|
@ -1995,6 +1995,72 @@ gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX
|
|||
gdFree (sty);
|
||||
}
|
||||
|
||||
/* gd 2.0.8: gdImageCopyRotated is added. Source
|
||||
is a rectangle, with its upper left corner at
|
||||
srcX and srcY. Destination is the *center* of
|
||||
the rotated copy. Angle is in degrees, same as
|
||||
gdImageArc. Floating point destination center
|
||||
coordinates allow accurate rotation of
|
||||
objects of odd-numbered width or height. */
|
||||
|
||||
void
|
||||
gdImageCopyRotated (gdImagePtr dst,
|
||||
gdImagePtr src,
|
||||
double dstX, double dstY,
|
||||
int srcX, int srcY,
|
||||
int srcWidth, int srcHeight,
|
||||
int angle)
|
||||
{
|
||||
double dx, dy;
|
||||
double radius = sqrt(srcWidth * srcWidth + srcHeight * srcHeight);
|
||||
double aCos = cos(angle * .0174532925);
|
||||
double aSin = sin(angle * .0174532925);
|
||||
double scX = srcX + ((double) srcWidth) / 2;
|
||||
double scY = srcY + ((double) srcHeight) / 2;
|
||||
int cmap[gdMaxColors];
|
||||
int i;
|
||||
for (i = 0; (i < gdMaxColors); i++)
|
||||
{
|
||||
cmap[i] = (-1);
|
||||
}
|
||||
for (dy = dstY - radius; (dy <= dstY + radius); dy++) {
|
||||
for (dx = dstX - radius; (dx <= dstX + radius); dx++) {
|
||||
double sxd = (dx - dstX) * aCos - (dy - dstY) * aSin;
|
||||
double syd = (dy - dstY) * aCos + (dx - dstX) * aSin;
|
||||
int sx = sxd + scX;
|
||||
int sy = syd + scY;
|
||||
if ((sx >= srcX) && (sx < srcX + srcWidth) &&
|
||||
(sy >= srcY) && (sy < srcY + srcHeight))
|
||||
{
|
||||
int c = gdImageGetPixel(src, sx, sy);
|
||||
if (!src->trueColor) {
|
||||
/* Use a table to avoid an expensive
|
||||
lookup on every single pixel */
|
||||
if (cmap[c] == -1) {
|
||||
cmap[c] = gdImageColorResolveAlpha(
|
||||
dst,
|
||||
gdImageRed(src, c),
|
||||
gdImageGreen(src, c),
|
||||
gdImageBlue(src, c),
|
||||
gdImageAlpha(src, c));
|
||||
}
|
||||
gdImageSetPixel(dst,
|
||||
dx, dy, cmap[c]);
|
||||
} else {
|
||||
gdImageSetPixel(dst,
|
||||
dx, dy,
|
||||
gdImageColorResolveAlpha(
|
||||
dst,
|
||||
gdImageRed(src, c),
|
||||
gdImageGreen(src, c),
|
||||
gdImageBlue(src, c),
|
||||
gdImageAlpha(src, c)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 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
|
||||
|
@ -2077,10 +2143,12 @@ gdImageCopyResampled (gdImagePtr dst,
|
|||
xportion = 1.0;
|
||||
}
|
||||
pcontribution = xportion * yportion;
|
||||
/* 2.08: previously srcX and srcY were ignored.
|
||||
Andrew Pattison */
|
||||
p = gdImageGetTrueColorPixel (
|
||||
src,
|
||||
(int) sx,
|
||||
(int) sy);
|
||||
(int) sx + srcX,
|
||||
(int) sy + srcY);
|
||||
red += gdTrueColorGetRed (p) * pcontribution;
|
||||
green += gdTrueColorGetGreen (p) * pcontribution;
|
||||
blue += gdTrueColorGetBlue (p) * pcontribution;
|
||||
|
|
14
src/gd.h
14
src/gd.h
|
@ -438,6 +438,20 @@ void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int
|
|||
substituted automatically. */
|
||||
void gdImageCopyResampled(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
|
||||
|
||||
/* gd 2.0.8: gdImageCopyRotated is added. Source
|
||||
is a rectangle, with its upper left corner at
|
||||
srcX and srcY. Destination is the *center* of
|
||||
the rotated copy. Angle is in degrees, same as
|
||||
gdImageArc. Floating point destination center
|
||||
coordinates allow accurate rotation of
|
||||
objects of odd-numbered width or height. */
|
||||
void gdImageCopyRotated (gdImagePtr dst,
|
||||
gdImagePtr src,
|
||||
double dstX, double dstY,
|
||||
int srcX, int srcY,
|
||||
int srcWidth, int srcHeight,
|
||||
int angle);
|
||||
|
||||
void gdImageSetBrush(gdImagePtr im, gdImagePtr brush);
|
||||
void gdImageSetTile(gdImagePtr im, gdImagePtr tile);
|
||||
void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels);
|
||||
|
|
16
src/gddemo.c
16
src/gddemo.c
|
@ -31,14 +31,13 @@ main (void)
|
|||
/* Points for polygon */
|
||||
gdPoint points[3];
|
||||
|
||||
/* Create output image, 256 by 256 pixels, true color. */
|
||||
im_out = gdImageCreateTrueColor (256, 256);
|
||||
|
||||
/* Create output image, in true color. */
|
||||
im_out = gdImageCreateTrueColor (256 + 384, 384);
|
||||
/* 2.0.2: first color allocated would automatically be background in a
|
||||
palette based image. Since this is a truecolor image, with an
|
||||
automatic background of black, we must fill it explicitly. */
|
||||
white = gdImageColorAllocate (im_out, 255, 255, 255);
|
||||
gdImageFilledRectangle(im_out, 0, 0, 256, 256, white);
|
||||
gdImageFilledRectangle(im_out, 0, 0, gdImageSX(im_out), gdImageSY(im_out), white);
|
||||
|
||||
/* Set transparent color. */
|
||||
gdImageColorTransparent (im_out, white);
|
||||
|
@ -55,11 +54,20 @@ main (void)
|
|||
}
|
||||
else
|
||||
{
|
||||
int a;
|
||||
im_in = gdImageCreateFromPng (in);
|
||||
fclose (in);
|
||||
/* Now copy, and magnify as we do so */
|
||||
gdImageCopyResized (im_out, im_in,
|
||||
32, 32, 0, 0, 192, 192, 255, 255);
|
||||
/* Now display variously rotated space shuttles in a circle of our own */
|
||||
for (a = 0; (a < 360); a += 45) {
|
||||
int cx = cos(a * .0174532925) * 128;
|
||||
int cy = - sin(a * .0174532925) * 128;
|
||||
gdImageCopyRotated(im_out, im_in,
|
||||
256 + 192 + cx, 192 + cy,
|
||||
0, 0, gdImageSX(im_in), gdImageSY(im_in), a);
|
||||
}
|
||||
}
|
||||
red = gdImageColorAllocate (im_out, 255, 0, 0);
|
||||
green = gdImageColorAllocate (im_out, 0, 255, 0);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<html>
|
||||
<head>
|
||||
<TITLE>gd 2.0.7</TITLE>
|
||||
<TITLE>gd 2.0.8</TITLE>
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<!-- BANNER HERE -->
|
||||
<h1>This is gd 2.0.7.</h1>
|
||||
<h1>This is gd 2.0.8.</h1>
|
||||
<p>
|
||||
<H2>gd 2.0.7</H2>
|
||||
<H2>gd 2.0.8</H2>
|
||||
<H3>A graphics library for fast image creation</H3>
|
||||
<H3>Follow this link to the
|
||||
<A HREF="http://www.boutell.com/gd/">latest version
|
||||
|
@ -22,7 +22,7 @@ To ensure that your
|
|||
new installation overwrites the old.
|
||||
<p>
|
||||
<strong>ABOUT GD AND GIF:</strong>
|
||||
gd 2.0.7 creates PNG, JPEG and WBMP images, not GIF images. This is a
|
||||
gd 2.0.8 creates PNG, JPEG and WBMP images, not GIF images. This is a
|
||||
good thing. PNG is a more compact format, and full compression is
|
||||
available. JPEG works best with photographic images, and is still
|
||||
more compatible with the major Web browsers than even PNG is. WBMP is
|
||||
|
@ -35,7 +35,7 @@ solution is to move to legally unencumbered, well-compressed,
|
|||
modern image formats such as PNG and JPEG as soon as possible.
|
||||
|
||||
<p>
|
||||
gd 2.0.7 <strong>requires</strong> that the following libraries
|
||||
gd 2.0.8 <strong>requires</strong> that the following libraries
|
||||
also be installed, in order to produce the related image formats:
|
||||
<p>
|
||||
libpng (see the <a href="http://www.libpng.org/pub/png/">libpng home page</a>), if you want PNG
|
||||
|
@ -65,7 +65,7 @@ information. Thank you!
|
|||
<H3>Table of Contents</H3>
|
||||
<UL>
|
||||
<LI><A HREF="#notice">Credits and license terms</A>
|
||||
<LI><A HREF="#whatsnew2.0.7">What's new in version "XYZ" of GD?</A>
|
||||
<LI><A HREF="#whatsnew2.0.8">What's new in version "XYZ" of GD?</A>
|
||||
<LI><A HREF="#whatis">What is gd?</A>
|
||||
<LI><A HREF="#gdother">What if I want to use another programming language?</A>
|
||||
<LI><A HREF="#required">What else do I need to use gd?</A>
|
||||
|
@ -164,7 +164,7 @@ and so forth.
|
|||
<A NAME="gdother"><H3>What if I want to use another programming
|
||||
language?</h3></A>
|
||||
Not all of these tools are necessarily up to date and fully compatible
|
||||
with 2.0.7.
|
||||
with 2.0.8.
|
||||
<h4>Perl</h4>
|
||||
gd can also be used from Perl, courtesy of
|
||||
Lincoln Stein's
|
||||
|
@ -192,6 +192,16 @@ invoke the interpreter.
|
|||
<li><a href="http://martin.gleeson.com/fly/">fly</a>, by Martin Gleeson
|
||||
</ul>
|
||||
<P>
|
||||
<A NAME="whatsnew2.0.8"><H3>What's new in version 2.0.8?</H3></A>
|
||||
<P>
|
||||
<ul>
|
||||
<li>Version 2.0.8 contains additional fixes to the 'configure' script,
|
||||
allowing a clean out-of-the-box build on more systems.
|
||||
<li>Version 2.0.8 adds the new
|
||||
<a href="#gdImageCopyRotated">gdImageCopyRotated</a> function, which
|
||||
can rotate any rectangular image region by an arbitrary number of degrees.
|
||||
</ul>
|
||||
<P>
|
||||
<A NAME="whatsnew2.0.7"><H3>What's new in version 2.0.7?</H3></A>
|
||||
<P>
|
||||
Version 2.0.7 corrects a problem which caused 'configure' to complain
|
||||
|
@ -718,8 +728,8 @@ saving of alpha channel information to the file instead.
|
|||
<P>
|
||||
<A NAME="getgd"><H3>How do I get gd?</H3></A>
|
||||
<ul>
|
||||
<li><a href="http://www.boutell.com/gd/http/gd-2.0.7.tar.gz">Gzipped Tar File (Unix)</a>
|
||||
<li><a href="http://www.boutell.com/gd/http/gd-2.0.7.zip">.ZIP File (Windows)</a>
|
||||
<li><a href="http://www.boutell.com/gd/http/gd-2.0.8.tar.gz">Gzipped Tar File (Unix)</a>
|
||||
<li><a href="http://www.boutell.com/gd/http/gd-2.0.8.zip">.ZIP File (Windows)</a>
|
||||
</ul>
|
||||
<P>
|
||||
<A NAME="buildgd"><H3>How do I build gd?</H3></A>
|
||||
|
@ -730,10 +740,10 @@ downloaded. If you are not familiar with <code>tar</code> and
|
|||
consult with an experienced user of your system. Sorry, we cannot
|
||||
answer questions about basic Internet skills.
|
||||
<p>
|
||||
Unpacking the archive will produce a directory called "gd-2.0.7".
|
||||
Unpacking the archive will produce a directory called "gd-2.0.8".
|
||||
<p>
|
||||
<h4>For Unix</h4>
|
||||
<code>cd</code> to the 2.0.7 directory and type:
|
||||
<code>cd</code> to the 2.0.8 directory and type:
|
||||
<p>
|
||||
<code>./configure</code>
|
||||
<P>
|
||||
|
@ -911,7 +921,7 @@ filling functions</A></LI>
|
|||
<LI><A HREF="#query">Query functions (not color-related)</A></LI>
|
||||
<LI><A HREF="#fonts">Font and text-handling functions</A></LI>
|
||||
<LI><A HREF="#colors">Color handling functions</A></LI>
|
||||
<LI><A HREF="#copying">Copying and resizing functions</A></LI>
|
||||
<LI><A HREF="#copying">Copying, resizing and rotating functions</A></LI>
|
||||
<LI><A HREF="#misc">Miscellaneous Functions</A></LI>
|
||||
<LI><A HREF="#constants">Constants</A></LI>
|
||||
</UL>
|
||||
|
@ -3128,7 +3138,7 @@ for both palette and truecolor images.
|
|||
int gdImageColorBlue(gdImagePtr im, int c)</A>
|
||||
<STRONG>(MACRO)</STRONG>
|
||||
<DD>
|
||||
gdImageColorBlue is a macro which returns the green portion
|
||||
gdImageColorBlue is a macro which returns the blue portion
|
||||
of the specified color in the image. This macro works
|
||||
for both palette and truecolor images.
|
||||
<DT><A NAME="gdImageGetInterlaced">
|
||||
|
@ -3452,6 +3462,64 @@ fclose(out);
|
|||
<A HREF="#gdImageDestroy">gdImageDestroy</A>(im_in);
|
||||
<A HREF="#gdImageDestroy">gdImageDestroy</A>(im_out);
|
||||
</PRE>
|
||||
<DT><A NAME="gdImageCopyRotated">void gdImageCopyRotated(gdImagePtr dst, gdImagePtr src, double dstX, double dstY, int srcX, int srcY, int srcW, int srcH, int angle)
|
||||
<STRONG> (FUNCTION)</STRONG>
|
||||
<DD>
|
||||
gdImageCopyRotated is used to copy a rectangular portion of one image to
|
||||
another image, or to another region of the same image. <strong>The srcX and
|
||||
srcY coordinates specify the upper left corner of the source area; however,
|
||||
the dstX and dstY coordinates specify the CENTER of the destination area.
|
||||
</strong> This important distinction is made because the rotated rectangle may
|
||||
may or may not be parallel to the X and Y axes. The destination coordinates
|
||||
may be floating point, as the center of the desired destination area may lie
|
||||
at the center of a pixel (0.5 pixels) rather than its upper left corner.
|
||||
The angle specified is an integer number of degrees, between 0 and 360,
|
||||
with 0 degrees causing no change, and counterclockwise rotation as
|
||||
the angle increases.
|
||||
<P>
|
||||
When you copy a region from one location in an image to another
|
||||
location in the same image, gdImageCopyRotated will perform as expected
|
||||
unless the regions overlap, in which case the result is
|
||||
unpredictable. If this presents a problem, create a scratch image
|
||||
in which to keep intermediate results.
|
||||
<P>
|
||||
<strong>Important note on copying between images:</strong> since
|
||||
palette-based images do not necessarily have the same color tables, pixels
|
||||
are not simply set to the same color index values to copy them.
|
||||
If the destination image is not a truecolor image,
|
||||
<a href="#gdImageColorResolveAlpha">gdImageColorResolveAlpha</a> is
|
||||
used to choose the destination pixel.
|
||||
<PRE>
|
||||
... Inside a function ...
|
||||
<A HREF="#gdImagePtr">gdImagePtr</A> im_in;
|
||||
<A HREF="#gdImagePtr">gdImagePtr</A> im_out;
|
||||
int x, y;
|
||||
int a;
|
||||
FILE *in;
|
||||
FILE *out;
|
||||
/* Load a small png to rotate in the larger one */
|
||||
in = fopen("small.png", "rb");
|
||||
im_in = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
|
||||
fclose(in);
|
||||
/* Make the output image four times as large on both axes */
|
||||
im_out = <A HREF="#gdImageCreate">gdImageCreate</A>(im_in->sx * 4, im_in->sy * 4);
|
||||
/* Now rotate the smaller image */
|
||||
for (a = 0; (a < 360); a += 45) {
|
||||
double x = cos(a * .0174532925) * gdImageSX(im_out) / 2;
|
||||
double y = -sin(a * .0174532925) * gdImageSY(im_out) / 2;
|
||||
gdImageCopyRotated(im_out, im_in,
|
||||
gdImageSX(im_out) / 2 + x,
|
||||
gdImageSY(im_out) / 2 + y,
|
||||
0, 0,
|
||||
gdImageSX(im_in),
|
||||
gdImageSY(im_in),
|
||||
a);
|
||||
out = fopen("large.png", "wb");
|
||||
<A HREF="#gdImagePng">gdImagePng</A>(im_out, out);
|
||||
fclose(out);
|
||||
<A HREF="#gdImageDestroy">gdImageDestroy</A>(im_in);
|
||||
<A HREF="#gdImageDestroy">gdImageDestroy</A>(im_out);
|
||||
</PRE>
|
||||
|
||||
<DT><A NAME="gdImageCopyMerge">void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
|
||||
<STRONG> (FUNCTION)</STRONG>
|
||||
|
@ -3778,6 +3846,7 @@ purchase gd support at the hourly rate above.
|
|||
<A HREF="#gdImageCopyMergeGray">gdImageMergeGray</A> |
|
||||
<A HREF="#gdImageCopyResized">gdImageCopyResized</A> |
|
||||
<A HREF="#gdImageCopyResampled">gdImageCopyResampled</A> |
|
||||
<A HREF="#gdImageCopyRotated">gdImageCopyRotated</A> |
|
||||
<A HREF="#gdImageCreate">gdImageCreate</A> |
|
||||
<A HREF="#gdImageCreate">gdImageCreatePalette</A> |
|
||||
<A HREF="#gdImageCreate">gdImageCreateTrueColor</A> |
|
||||
|
|
Loading…
Reference in New Issue