cvs: php-src /ext/gd gd.c /ext/gd/libgd gd.c gd.h gd_gd.c gd_gd2.c gd_io_dp.c gd_jpeg.c gd_png.c gd_wbmp.c gdfontg.c gdfontg.h gdfontl.c gdfontl.h
gdfontmb.c gdfontmb.h gdfonts.c gdfonts.h gdfontt.c gdfontt.h gdft.c
| From: | Ilia Alshanetsky | Date: | Mon, 29 Mar 2004 18:20:33 +0000 |
| Subject: | cvs: php-src /ext/gd gd.c /ext/gd/libgd gd.c gd.h gd_gd.c gd_gd2.c gd_io_dp.c gd_jpeg.c gd_png.c gd_wbmp.c gdfontg.c gdfontg.h gdfontl.c gdfontl.h gdfontmb.c gdfontmb.h gdfonts.c gdfonts.h gdfontt.c gdfontt.h gdft.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-26848@lists.php.net to get a copy of this message | ||
iliaa Mon Mar 29 13:20:33 2004 EDT
Modified files:
/php-src/ext/gd gd.c
/php-src/ext/gd/libgd gd.c gd.h gd_gd.c gd_gd2.c gd_io_dp.c
gd_jpeg.c gd_png.c gd_wbmp.c gdfontg.c
gdfontg.h gdfontl.c gdfontl.h gdfontmb.c
gdfontmb.h gdfonts.c gdfonts.h gdfontt.c
gdfontt.h gdft.c
Log:
Synchronized bundled GD library with GD 2.0.22.
http://cvs.php.net/diff.php/php-src/ext/gd/gd.c?r1=1.288&r2=1.289&ty=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.288 php-src/ext/gd/gd.c:1.289 --- php-src/ext/gd/gd.c:1.288 Sun Feb 22 13:03:09 2004 +++ php-src/ext/gd/gd.c Mon Mar 29 13:20:32 2004 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: gd.c,v 1.288 2004/02/22 18:03:09 iliaa Exp $ */ +/* $Id: gd.c,v 1.289 2004/03/29 18:20:32 iliaa Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -453,7 +453,7 @@ /* }}} */ #if HAVE_GD_BUNDLED -#define PHP_GD_VERSION_STRING "bundled (2.0.17 compatible)" +#define PHP_GD_VERSION_STRING "bundled (2.0.22 compatible)" #elif HAVE_LIBGD20 #define PHP_GD_VERSION_STRING "2.0 or higher" #elif HAVE_GDIMAGECOLORRESOLVE http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.76&r2=1.77&ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.76 php-src/ext/gd/libgd/gd.c:1.77 --- php-src/ext/gd/libgd/gd.c:1.76 Mon Mar 22 12:26:03 2004 +++ php-src/ext/gd/libgd/gd.c Mon Mar 29 13:20:33 2004 @@ -2300,7 +2300,8 @@ int tmp = gdImageGetPixel (src, x, y); mapTo = gdImageGetTrueColorPixel (src, x, y); if (gdImageGetTransparent (src) == tmp) { - tox++; + /* 2.0.21, TK: not tox++ */ + tox += stx[x - srcX]; continue; } } else { @@ -2308,7 +2309,8 @@ mapTo = gdImageGetTrueColorPixel (src, x, y); /* Added 7/24/95: support transparent copies */ if (gdImageGetTransparent (src) == mapTo) { - tox++; + /* 2.0.21, TK: not tox++ */ + tox += stx[x - srcX]; continue; } } @@ -2364,22 +2366,24 @@ void gdImageCopyResampled (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) { int x, y; + double sy1, sy2, sx1, sx2; if (!dst->trueColor) { gdImageCopyResized (dst, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); return; } for (y = dstY; (y < dstY + dstH); y++) { + sy1 = ((double) y - (double) dstY) * (double) srcH / (double) dstH; + sy2 = ((double) (y + 1) - (double) dstY) * (double) srcH / (double) dstH; for (x = dstX; (x < dstX + dstW); x++) { - float sy1, sy2, sx1, sx2; - float sx, sy; - float spixels = 0.0f; - float red = 0.0f, green = 0.0f, blue = 0.0f, alpha = 0.0f; - float alpha_factor, alpha_sum = 0.0f, contrib_sum = 0.0f; - sy1 = ((float)(y - dstY)) * (float)srcH / (float)dstH; - sy2 = ((float)(y + 1 - dstY)) * (float) srcH / (float) dstH; + double sx, sy; + double spixels = 0; + double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0; + double alpha_factor, alpha_sum = 0.0, contrib_sum = 0.0; + sx1 = ((double) x - (double) dstX) * (double) srcW / dstW; + sx2 = ((double) (x + 1) - (double) dstX) * (double) srcW / dstW; sy = sy1; do { - float yportion; + double yportion; if (floor_cast(sy) == floor_cast(sy1)) { yportion = 1.0f - (sy - floor_cast(sy)); if (yportion > sy2 - sy1) { @@ -2391,12 +2395,10 @@ } else { yportion = 1.0f; } - sx1 = ((float)(x - dstX)) * (float) srcW / dstW; - sx2 = ((float)(x + 1 - dstX)) * (float) srcW / dstW; sx = sx1; do { - float xportion; - float pcontribution; + double xportion; + double pcontribution; int p; if (floorf(sx) == floor_cast(sx1)) { xportion = 1.0f - (sx - floor_cast(sx)); http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.h?r1=1.20&r2=1.21&ty=u Index: php-src/ext/gd/libgd/gd.h diff -u php-src/ext/gd/libgd/gd.h:1.20 php-src/ext/gd/libgd/gd.h:1.21 --- php-src/ext/gd/libgd/gd.h:1.20 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd.h Mon Mar 29 13:20:33 2004 @@ -579,6 +579,7 @@ gdIOCtx* gdNewFileCtx(FILE*); gdIOCtx* gdNewDynamicCtx(int, void*); +gdIOCtx *gdNewDynamicCtxEx(int size, void *data, int freeFlag); gdIOCtx* gdNewSSCtx(gdSourcePtr in, gdSinkPtr out); void* gdDPExtractData(struct gdIOCtx* ctx, int *size); http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd_gd.c?r1=1.7&r2=1.8&ty=u Index: php-src/ext/gd/libgd/gd_gd.c diff -u php-src/ext/gd/libgd/gd_gd.c:1.7 php-src/ext/gd/libgd/gd_gd.c:1.8 --- php-src/ext/gd/libgd/gd_gd.c:1.7 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd_gd.c Mon Mar 29 13:20:33 2004 @@ -146,6 +146,16 @@ return im; } +gdImagePtr gdImageCreateFromGdPtr (int size, void *data) +{ + gdImagePtr im; + gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0); + im = gdImageCreateFromGdCtx(in); + in->gd_free(in); + + return im; +} + gdImagePtr gdImageCreateFromGdCtx (gdIOCtxPtr in) { int sx, sy; http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd_gd2.c?r1=1.15&r2=1.16&ty=u Index: php-src/ext/gd/libgd/gd_gd2.c diff -u php-src/ext/gd/libgd/gd_gd2.c:1.15 php-src/ext/gd/libgd/gd_gd2.c:1.16 --- php-src/ext/gd/libgd/gd_gd2.c:1.15 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd_gd2.c Mon Mar 29 13:20:33 2004 @@ -236,6 +236,16 @@ return im; } +gdImagePtr gdImageCreateFromGd2Ptr (int size, void *data) +{ + gdImagePtr im; + gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0); + im = gdImageCreateFromGd2Ctx(in); + in->gd_free(in); + + return im; +} + gdImagePtr gdImageCreateFromGd2Ctx (gdIOCtxPtr in) { int sx, sy; @@ -377,6 +387,16 @@ return 0; } +gdImagePtr gdImageCreateFromGd2PartPtr (int size, void *data, int srcx, int srcy, int w, int h) +{ + gdImagePtr im; + gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0); + im = gdImageCreateFromGd2PartCtx(in, srcx, srcy, w, h); + in->gd_free(in); + + return im; +} + gdImagePtr gdImageCreateFromGd2Part (FILE * inFile, int srcx, int srcy, int w, int h) { gdImagePtr im; http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd_io_dp.c?r1=1.5&r2=1.6&ty=u Index: php-src/ext/gd/libgd/gd_io_dp.c diff -u php-src/ext/gd/libgd/gd_io_dp.c:1.5 php-src/ext/gd/libgd/gd_io_dp.c:1.6 --- php-src/ext/gd/libgd/gd_io_dp.c:1.5 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd_io_dp.c Mon Mar 29 13:20:33 2004 @@ -33,6 +33,7 @@ int realSize; int dataGood; int pos; + int freeOK; } dynamicPtr; typedef struct dpIOCtx @@ -49,7 +50,7 @@ static int gdReallocDynamic (dynamicPtr * dp, int required); static int trimDynamic (dynamicPtr * dp); static void gdFreeDynamicCtx (struct gdIOCtx *ctx); -static dynamicPtr *newDynamic (int initialSize, void *data); +static dynamicPtr *newDynamic (int initialSize, void *data, int freeOKFlag); static int dynamicPutbuf (struct gdIOCtx *, const void *, int); static void dynamicPutchar (struct gdIOCtx *, int a); @@ -63,12 +64,17 @@ /* return data as a dynamic pointer */ gdIOCtx * gdNewDynamicCtx (int initialSize, void *data) { + return gdNewDynamicCtxEx(initialSize, data, 1); +} + +gdIOCtx * gdNewDynamicCtxEx (int initialSize, void *data, int freeOKFlag) +{ dpIOCtx *ctx; dynamicPtr *dp; ctx = (dpIOCtx *) gdMalloc (sizeof (dpIOCtx)); - dp = newDynamic(initialSize, data); + dp = newDynamic(initialSize, data, freeOKFlag); ctx->dp = dp; @@ -103,7 +109,7 @@ } else { *size = 0; data = NULL; - if (dp->data != NULL) { + if (dp->data != NULL && dp->freeOK) { gdFree(dp->data); } } @@ -155,6 +161,10 @@ bytesNeeded = pos; if (bytesNeeded > dp->realSize) { + /* 2.0.21 */ + if (!dp->freeOK) { + return FALSE; + } gdReallocDynamic (dp, dp->realSize * 2); } @@ -171,7 +181,7 @@ } /* return data as a dynamic pointer */ -static dynamicPtr * newDynamic (int initialSize, void *data) +static dynamicPtr * newDynamic (int initialSize, void *data, int freeOKFlag) { dynamicPtr *dp; dp = (dynamicPtr *) gdMalloc (sizeof (dynamicPtr)); @@ -179,6 +189,7 @@ allocDynamic (dp, initialSize, data); dp->pos = 0; + dp->freeOK = freeOKFlag; return dp; } @@ -292,6 +303,10 @@ bytesNeeded = dp->pos + size; if (bytesNeeded > dp->realSize) { + /* 2.0.21 */ + if (!dp->freeOK) { + return FALSE; + } gdReallocDynamic(dp, bytesNeeded * 2); } @@ -337,5 +352,9 @@ /* trim pointer so that its real and logical sizes match */ static int trimDynamic (dynamicPtr * dp) { + /* 2.0.21: we don't reallocate memory we don't own */ + if (!dp->freeOK) { + return FALSE; + } return gdReallocDynamic(dp, dp->logicalSize); } http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd_jpeg.c?r1=1.17&r2=1.18&ty=u Index: php-src/ext/gd/libgd/gd_jpeg.c diff -u php-src/ext/gd/libgd/gd_jpeg.c:1.17 php-src/ext/gd/libgd/gd_jpeg.c:1.18 --- php-src/ext/gd/libgd/gd_jpeg.c:1.17 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd_jpeg.c Mon Mar 29 13:20:33 2004 @@ -217,8 +217,20 @@ return im; } +gdImagePtr gdImageCreateFromJpegPtr (int size, void *data) +{ + gdImagePtr im; + gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0); + im = gdImageCreateFromJpegCtx(in); + in->gd_free(in); + + return im; +} + void jpeg_gdIOCtx_src (j_decompress_ptr cinfo, gdIOCtx * infile); +static int CMYKToRGB(int c, int m, int y, int k, int inverted); + /* * Create a gd-format image from the JPEG-format INFILE. Returns the * image, or NULL upon error. @@ -235,6 +247,8 @@ unsigned int i, j; int retval; JDIMENSION nrows; + int channels = 3; + int inverted = 0; memset (&cinfo, 0, sizeof (cinfo)); memset (&jerr, 0, sizeof (jerr)); @@ -258,6 +272,9 @@ jpeg_gdIOCtx_src (&cinfo, infile); + /* 2.0.22: save the APP14 marker to check for Adobe Photoshop CMYK files with inverted components. */ + jpeg_save_markers(&cinfo, JPEG_APP0 + 14, 256); + retval = jpeg_read_header (&cinfo, TRUE); if (retval != JPEG_HEADER_OK) { php_gd_error_ex(E_WARNING, "gd-jpeg: warning: jpeg_read_header returned %d, expected %d", retval, JPEG_HEADER_OK); @@ -277,8 +294,14 @@ goto error; } - /* Force the image into RGB colorspace, but don't reduce the number of colors anymore (GD 2.0) */ - cinfo.out_color_space = JCS_RGB; + /* 2.0.22: very basic support for reading CMYK colorspace files. Nice for + * thumbnails but there's no support for fussy adjustment of the + * assumed properties of inks and paper. */ + if ((cinfo.jpeg_color_space == JCS_CMYK) || (cinfo.jpeg_color_space == JCS_YCCK)) { + cinfo.out_color_space = JCS_CMYK; + } else { + cinfo.out_color_space = JCS_RGB; + } if (jpeg_start_decompress (&cinfo) != TRUE) { php_gd_error("gd-jpeg: warning: jpeg_start_decompress reports suspended data source"); @@ -297,8 +320,29 @@ gdImageInterlace (im, cinfo.progressive_mode != 0); #endif - if (cinfo.output_components != 3) { - php_gd_error_ex(E_WARNING, "gd-jpeg: error: JPEG color quantization request resulted in output_components == %d (expected 3)", cinfo.output_components); + if (cinfo.out_color_space == JCS_RGB) { + if (cinfo.output_components != 3) { + php_gd_error_ex(E_WARNING, "gd-jpeg: error: JPEG color quantization request resulted in output_components == %d (expected 3 for RGB)", cinfo.output_components); + goto error; + } + channels = 3; + } else if (cinfo.out_color_space == JCS_CMYK) { + jpeg_saved_marker_ptr marker; + if (cinfo.output_components != 4) { + php_gd_error_ex(E_WARNING, "gd-jpeg: error: JPEG color quantization request resulted in output_components == %d (expected 4 for CMYK)", cinfo.output_components); + goto error; + } + channels = 4; + marker = cinfo.marker_list; + while (marker) { + if ((marker->marker == (JPEG_APP0 + 14)) && (marker->data_length >= 12) && (!strncmp((const char *) marker->data, "Adobe", 5))) { + inverted = 1; + break; + } + marker = marker->next; + } + } else { + php_gd_error_ex(E_WARNING, "gd-jpeg: error: unexpected colorspace."); goto error; } @@ -307,22 +351,37 @@ goto error; #endif /* BITS_IN_JSAMPLE == 12 */ - row = safe_emalloc(cinfo.output_width * 3, sizeof(JSAMPLE), 0); - memset(row, 0, cinfo.output_width * 3 * sizeof(JSAMPLE)); + row = safe_emalloc(cinfo.output_width * channels, sizeof(JSAMPLE), 0); + memset(row, 0, cinfo.output_width * channels * sizeof(JSAMPLE)); rowptr[0] = row; - for (i = 0; i < cinfo.output_height; i++) { - register JSAMPROW currow = row; - register int *tpix = im->tpixels[i]; - nrows = jpeg_read_scanlines (&cinfo, rowptr, 1); - if (nrows != 1) { - php_gd_error_ex(E_WARNING, "gd-jpeg: error: jpeg_read_scanlines returns %u, expected 1", nrows); - goto error; + if (cinfo.out_color_space == JCS_CMYK) { + for (i = 0; i < cinfo.output_height; i++) { + register JSAMPROW currow = row; + register int *tpix = im->tpixels[i]; + nrows = jpeg_read_scanlines (&cinfo, rowptr, 1); + if (nrows != 1) { + php_gd_error_ex(E_WARNING, "gd-jpeg: error: jpeg_read_scanlines returns %u, expected 1", nrows); + goto error; + } + for (j = 0; j < cinfo.output_width; j++, currow += 4, tpix++) { + *tpix = CMYKToRGB (currow[0], currow[1], currow[2], currow[3], inverted); + } } - for (j = 0; j < cinfo.output_width; j++, currow += 3, tpix++) { - *tpix = gdTrueColor (currow[0], currow[1], currow[2]); + } else { + for (i = 0; i < cinfo.output_height; i++) { + register JSAMPROW currow = row; + register int *tpix = im->tpixels[i]; + nrows = jpeg_read_scanlines (&cinfo, rowptr, 1); + if (nrows != 1) { + php_gd_error_ex(E_WARNING, "gd-jpeg: error: jpeg_read_scanlines returns %u, expected 1", nrows); + goto error; + } + for (j = 0; j < cinfo.output_width; j++, currow += 3, tpix++) { + *tpix = gdTrueColor (currow[0], currow[1], currow[2]); + } } - } + } if (jpeg_finish_decompress (&cinfo) != TRUE) { php_gd_error("gd-jpeg: warning: jpeg_finish_decompress reports suspended data source"); @@ -349,8 +408,19 @@ return 0; } -/* +/* A very basic conversion approach, TBB */ +static int CMYKToRGB(int c, int m, int y, int k, int inverted) +{ + if (inverted) { + c = 255 - c; + m = 255 - m; + y = 255 - y; + k = 255 - k; + } + return gdTrueColor((255 - c) * (255 - k) / 255, (255 - m) * (255 - k) / 255, (255 - y) * (255 - k) / 255); +} +/* * gdIOCtx JPEG data sources and sinks, T. Boutell * almost a simple global replace from T. Lane's stdio versions. * http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd_png.c?r1=1.16&r2=1.17&ty=u Index: php-src/ext/gd/libgd/gd_png.c diff -u php-src/ext/gd/libgd/gd_png.c:1.16 php-src/ext/gd/libgd/gd_png.c:1.17 --- php-src/ext/gd/libgd/gd_png.c:1.16 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd_png.c Mon Mar 29 13:20:33 2004 @@ -93,6 +93,14 @@ return im; } +gdImagePtr gdImageCreateFromPngPtr (int size, void *data) +{ + gdImagePtr im; + gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0); + im = gdImageCreateFromPngCtx(in); + in->gd_free(in); + return im; +} /* This routine is based in part on the Chapter 13 demo code in "PNG: The * Definitive Guide" (http://www.cdrom.com/pub/png/pngbook.html). http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd_wbmp.c?r1=1.7&r2=1.8&ty=u Index: php-src/ext/gd/libgd/gd_wbmp.c diff -u php-src/ext/gd/libgd/gd_wbmp.c:1.7 php-src/ext/gd/libgd/gd_wbmp.c:1.8 --- php-src/ext/gd/libgd/gd_wbmp.c:1.7 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd_wbmp.c Mon Mar 29 13:20:33 2004 @@ -176,6 +176,15 @@ return im; } +gdImagePtr gdImageCreateFromWBMPPtr (int size, void *data) +{ + gdImagePtr im; + gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0); + im = gdImageCreateFromWBMPCtx(in); + in->gd_free(in); + return im; +} + /* gdImageWBMP ** ----------- */ http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontg.c?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontg.c diff -u php-src/ext/gd/libgd/gdfontg.c:1.1 php-src/ext/gd/libgd/gdfontg.c:1.2 --- php-src/ext/gd/libgd/gdfontg.c:1.1 Fri Apr 12 22:03:08 2002 +++ php-src/ext/gd/libgd/gdfontg.c Mon Mar 29 13:20:33 2004 @@ -4381,4 +4381,9 @@ gdFontPtr gdFontGiant = &gdFontGiantRep; +gdFontPtr gdFontGetGiant(void) +{ + return gdFontGiant; +} + /* This file has not been truncated. */ http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontg.h?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontg.h diff -u php-src/ext/gd/libgd/gdfontg.h:1.1 php-src/ext/gd/libgd/gdfontg.h:1.2 --- php-src/ext/gd/libgd/gdfontg.h:1.1 Fri Apr 12 22:03:08 2002 +++ php-src/ext/gd/libgd/gdfontg.h Mon Mar 29 13:20:33 2004 @@ -20,6 +20,7 @@ #include "gd.h" extern gdFontPtr gdFontGiant; +extern gdFontPtr gdFontGetGiant(void); #ifdef __cplusplus } http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontl.c?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontl.c diff -u php-src/ext/gd/libgd/gdfontl.c:1.1 php-src/ext/gd/libgd/gdfontl.c:1.2 --- php-src/ext/gd/libgd/gdfontl.c:1.1 Fri Apr 12 22:03:08 2002 +++ php-src/ext/gd/libgd/gdfontl.c Mon Mar 29 13:20:33 2004 @@ -4638,4 +4638,9 @@ gdFontPtr gdFontLarge = &gdFontLargeRep; +gdFontPtr gdFontGetLarge(void) +{ + return gdFontLarge; +} + /* This file has not been truncated. */ http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontl.h?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontl.h diff -u php-src/ext/gd/libgd/gdfontl.h:1.1 php-src/ext/gd/libgd/gdfontl.h:1.2 --- php-src/ext/gd/libgd/gdfontl.h:1.1 Fri Apr 12 22:03:08 2002 +++ php-src/ext/gd/libgd/gdfontl.h Mon Mar 29 13:20:33 2004 @@ -21,6 +21,7 @@ #include "gd.h" extern gdFontPtr gdFontLarge; +extern gdFontPtr gdFontGetLarge(void); #ifdef __cplusplus } http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontmb.c?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontmb.c diff -u php-src/ext/gd/libgd/gdfontmb.c:1.1 php-src/ext/gd/libgd/gdfontmb.c:1.2 --- php-src/ext/gd/libgd/gdfontmb.c:1.1 Fri Apr 12 22:03:08 2002 +++ php-src/ext/gd/libgd/gdfontmb.c Mon Mar 29 13:20:33 2004 @@ -3868,4 +3868,9 @@ gdFontPtr gdFontMediumBold = &gdFontMediumBoldRep; +gdFontPtr gdFontGetMediumBold(void) +{ + return gdFontMediumBold; +} + /* This file has not been truncated. */ http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontmb.h?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontmb.h diff -u php-src/ext/gd/libgd/gdfontmb.h:1.1 php-src/ext/gd/libgd/gdfontmb.h:1.2 --- php-src/ext/gd/libgd/gdfontmb.h:1.1 Fri Apr 12 22:03:08 2002 +++ php-src/ext/gd/libgd/gdfontmb.h Mon Mar 29 13:20:33 2004 @@ -19,6 +19,7 @@ #include "gd.h" extern gdFontPtr gdFontMediumBold; +extern gdFontPtr gdFontGetMediumBold(void); #ifdef __cplusplus } http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfonts.c?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfonts.c diff -u php-src/ext/gd/libgd/gdfonts.c:1.1 php-src/ext/gd/libgd/gdfonts.c:1.2 --- php-src/ext/gd/libgd/gdfonts.c:1.1 Fri Apr 12 22:03:09 2002 +++ php-src/ext/gd/libgd/gdfonts.c Mon Mar 29 13:20:33 2004 @@ -3868,4 +3868,9 @@ gdFontPtr gdFontSmall = &gdFontSmallRep; +gdFontPtr gdFontGetSmall(void) +{ + return gdFontSmall; +} + /* This file has not been truncated. */ http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfonts.h?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfonts.h diff -u php-src/ext/gd/libgd/gdfonts.h:1.1 php-src/ext/gd/libgd/gdfonts.h:1.2 --- php-src/ext/gd/libgd/gdfonts.h:1.1 Fri Apr 12 22:03:09 2002 +++ php-src/ext/gd/libgd/gdfonts.h Mon Mar 29 13:20:33 2004 @@ -19,6 +19,7 @@ #include "gd.h" extern gdFontPtr gdFontSmall; +extern gdFontPtr gdFontGetSmall(void); #ifdef __cplusplus } http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontt.c?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontt.c diff -u php-src/ext/gd/libgd/gdfontt.c:1.1 php-src/ext/gd/libgd/gdfontt.c:1.2 --- php-src/ext/gd/libgd/gdfontt.c:1.1 Fri Apr 12 22:03:09 2002 +++ php-src/ext/gd/libgd/gdfontt.c Mon Mar 29 13:20:33 2004 @@ -2589,4 +2589,9 @@ gdFontPtr gdFontTiny = &gdFontTinyRep; +gdFontPtr gdFontGetTiny(void) +{ + return gdFontTiny; +} + /* This file has not been truncated. */ http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontt.h?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontt.h diff -u php-src/ext/gd/libgd/gdfontt.h:1.1 php-src/ext/gd/libgd/gdfontt.h:1.2 --- php-src/ext/gd/libgd/gdfontt.h:1.1 Fri Apr 12 22:03:09 2002 +++ php-src/ext/gd/libgd/gdfontt.h Mon Mar 29 13:20:33 2004 @@ -20,6 +20,7 @@ #include "gd.h" extern gdFontPtr gdFontTiny; +extern gdFontPtr gdFontGetTiny(void); #ifdef __cplusplus } http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdft.c?r1=1.32&r2=1.33&ty=u Index: php-src/ext/gd/libgd/gdft.c diff -u php-src/ext/gd/libgd/gdft.c:1.32 php-src/ext/gd/libgd/gdft.c:1.33 --- php-src/ext/gd/libgd/gdft.c:1.32 Sat Mar 6 13:24:41 2004 +++ php-src/ext/gd/libgd/gdft.c Mon Mar 29 13:20:33 2004 @@ -80,9 +80,9 @@ /* * The character (space) used to separate alternate fonts in the - * fontlist parameter to gdImageStringFT. + * fontlist parameter to gdImageStringFT. 2.0.18: space was a oor choice for this. */ -#define LISTSEPARATOR " " +#define LISTSEPARATOR ";" /* * DEFAULT_FONTPATH and PATHSEPARATOR are host type dependent and @@ -434,7 +434,7 @@ encoding = charmap->encoding_id; /* EAM DEBUG - Newer versions of libfree2 make it easier by defining encodings */ -#ifdef FT_ENCODING_MS_SYMBOL +#if (defined(FREETYPE_MAJOR) && (FREETYPE_MAJOR >=2 ) && (FREETYPE_MINOR >= 1)) if (charmap->encoding == FT_ENCODING_MS_SYMBOL || charmap->encoding == FT_ENCODING_ADOBE_CUSTOM || charmap->encoding == FT_ENCODING_ADOBE_STANDARD) { @@ -443,7 +443,7 @@ a->face->charmap = charmap; return (void *)a; } -#endif /* FT_ENCODING_MS_SYMBOL */ +#endif /* Freetype 2.1 or better */ /* EAM DEBUG */ if ((platform == 3 && encoding == 1) /* Windows Unicode */ @@ -707,6 +707,11 @@ } } +void gdFreeFontCache() +{ + gdFontCacheShutdown(); +} + int gdFontCacheSetup(void) { if (fontCache) { @@ -895,7 +900,7 @@ } /* EAM DEBUG */ -#ifdef FT_ENCODING_MS_SYMBOL +#if (defined(FREETYPE_MAJOR) && (FREETYPE_MAJOR >=2 ) && (FREETYPE_MINOR >= 1)) if (font->face->charmap->encoding == FT_ENCODING_MS_SYMBOL) { /* I do not know the significance of the constant 0xf000. * It was determined by inspection of the character codes @@ -905,7 +910,7 @@ ch |= 0xf000; next += len; } else -#endif /* FT_ENCODING_MS_SYMBOL */ +#endif /* Freetype 2.1 or better */ /* EAM DEBUG */ switch (m) {
http://cvs.php.net/diff.php/php-src/ext/gd/gd.c?r1=1.288&r2=1.289&ty=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.288 php-src/ext/gd/gd.c:1.289 --- php-src/ext/gd/gd.c:1.288 Sun Feb 22 13:03:09 2004 +++ php-src/ext/gd/gd.c Mon Mar 29 13:20:32 2004 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: gd.c,v 1.288 2004/02/22 18:03:09 iliaa Exp $ */ +/* $Id: gd.c,v 1.289 2004/03/29 18:20:32 iliaa Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -453,7 +453,7 @@ /* }}} */ #if HAVE_GD_BUNDLED -#define PHP_GD_VERSION_STRING "bundled (2.0.17 compatible)" +#define PHP_GD_VERSION_STRING "bundled (2.0.22 compatible)" #elif HAVE_LIBGD20 #define PHP_GD_VERSION_STRING "2.0 or higher" #elif HAVE_GDIMAGECOLORRESOLVE http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.76&r2=1.77&ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.76 php-src/ext/gd/libgd/gd.c:1.77 --- php-src/ext/gd/libgd/gd.c:1.76 Mon Mar 22 12:26:03 2004 +++ php-src/ext/gd/libgd/gd.c Mon Mar 29 13:20:33 2004 @@ -2300,7 +2300,8 @@ int tmp = gdImageGetPixel (src, x, y); mapTo = gdImageGetTrueColorPixel (src, x, y); if (gdImageGetTransparent (src) == tmp) { - tox++; + /* 2.0.21, TK: not tox++ */ + tox += stx[x - srcX]; continue; } } else { @@ -2308,7 +2309,8 @@ mapTo = gdImageGetTrueColorPixel (src, x, y); /* Added 7/24/95: support transparent copies */ if (gdImageGetTransparent (src) == mapTo) { - tox++; + /* 2.0.21, TK: not tox++ */ + tox += stx[x - srcX]; continue; } } @@ -2364,22 +2366,24 @@ void gdImageCopyResampled (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) { int x, y; + double sy1, sy2, sx1, sx2; if (!dst->trueColor) { gdImageCopyResized (dst, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); return; } for (y = dstY; (y < dstY + dstH); y++) { + sy1 = ((double) y - (double) dstY) * (double) srcH / (double) dstH; + sy2 = ((double) (y + 1) - (double) dstY) * (double) srcH / (double) dstH; for (x = dstX; (x < dstX + dstW); x++) { - float sy1, sy2, sx1, sx2; - float sx, sy; - float spixels = 0.0f; - float red = 0.0f, green = 0.0f, blue = 0.0f, alpha = 0.0f; - float alpha_factor, alpha_sum = 0.0f, contrib_sum = 0.0f; - sy1 = ((float)(y - dstY)) * (float)srcH / (float)dstH; - sy2 = ((float)(y + 1 - dstY)) * (float) srcH / (float) dstH; + double sx, sy; + double spixels = 0; + double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0; + double alpha_factor, alpha_sum = 0.0, contrib_sum = 0.0; + sx1 = ((double) x - (double) dstX) * (double) srcW / dstW; + sx2 = ((double) (x + 1) - (double) dstX) * (double) srcW / dstW; sy = sy1; do { - float yportion; + double yportion; if (floor_cast(sy) == floor_cast(sy1)) { yportion = 1.0f - (sy - floor_cast(sy)); if (yportion > sy2 - sy1) { @@ -2391,12 +2395,10 @@ } else { yportion = 1.0f; } - sx1 = ((float)(x - dstX)) * (float) srcW / dstW; - sx2 = ((float)(x + 1 - dstX)) * (float) srcW / dstW; sx = sx1; do { - float xportion; - float pcontribution; + double xportion; + double pcontribution; int p; if (floorf(sx) == floor_cast(sx1)) { xportion = 1.0f - (sx - floor_cast(sx)); http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.h?r1=1.20&r2=1.21&ty=u Index: php-src/ext/gd/libgd/gd.h diff -u php-src/ext/gd/libgd/gd.h:1.20 php-src/ext/gd/libgd/gd.h:1.21 --- php-src/ext/gd/libgd/gd.h:1.20 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd.h Mon Mar 29 13:20:33 2004 @@ -579,6 +579,7 @@ gdIOCtx* gdNewFileCtx(FILE*); gdIOCtx* gdNewDynamicCtx(int, void*); +gdIOCtx *gdNewDynamicCtxEx(int size, void *data, int freeFlag); gdIOCtx* gdNewSSCtx(gdSourcePtr in, gdSinkPtr out); void* gdDPExtractData(struct gdIOCtx* ctx, int *size); http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd_gd.c?r1=1.7&r2=1.8&ty=u Index: php-src/ext/gd/libgd/gd_gd.c diff -u php-src/ext/gd/libgd/gd_gd.c:1.7 php-src/ext/gd/libgd/gd_gd.c:1.8 --- php-src/ext/gd/libgd/gd_gd.c:1.7 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd_gd.c Mon Mar 29 13:20:33 2004 @@ -146,6 +146,16 @@ return im; } +gdImagePtr gdImageCreateFromGdPtr (int size, void *data) +{ + gdImagePtr im; + gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0); + im = gdImageCreateFromGdCtx(in); + in->gd_free(in); + + return im; +} + gdImagePtr gdImageCreateFromGdCtx (gdIOCtxPtr in) { int sx, sy; http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd_gd2.c?r1=1.15&r2=1.16&ty=u Index: php-src/ext/gd/libgd/gd_gd2.c diff -u php-src/ext/gd/libgd/gd_gd2.c:1.15 php-src/ext/gd/libgd/gd_gd2.c:1.16 --- php-src/ext/gd/libgd/gd_gd2.c:1.15 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd_gd2.c Mon Mar 29 13:20:33 2004 @@ -236,6 +236,16 @@ return im; } +gdImagePtr gdImageCreateFromGd2Ptr (int size, void *data) +{ + gdImagePtr im; + gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0); + im = gdImageCreateFromGd2Ctx(in); + in->gd_free(in); + + return im; +} + gdImagePtr gdImageCreateFromGd2Ctx (gdIOCtxPtr in) { int sx, sy; @@ -377,6 +387,16 @@ return 0; } +gdImagePtr gdImageCreateFromGd2PartPtr (int size, void *data, int srcx, int srcy, int w, int h) +{ + gdImagePtr im; + gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0); + im = gdImageCreateFromGd2PartCtx(in, srcx, srcy, w, h); + in->gd_free(in); + + return im; +} + gdImagePtr gdImageCreateFromGd2Part (FILE * inFile, int srcx, int srcy, int w, int h) { gdImagePtr im; http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd_io_dp.c?r1=1.5&r2=1.6&ty=u Index: php-src/ext/gd/libgd/gd_io_dp.c diff -u php-src/ext/gd/libgd/gd_io_dp.c:1.5 php-src/ext/gd/libgd/gd_io_dp.c:1.6 --- php-src/ext/gd/libgd/gd_io_dp.c:1.5 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd_io_dp.c Mon Mar 29 13:20:33 2004 @@ -33,6 +33,7 @@ int realSize; int dataGood; int pos; + int freeOK; } dynamicPtr; typedef struct dpIOCtx @@ -49,7 +50,7 @@ static int gdReallocDynamic (dynamicPtr * dp, int required); static int trimDynamic (dynamicPtr * dp); static void gdFreeDynamicCtx (struct gdIOCtx *ctx); -static dynamicPtr *newDynamic (int initialSize, void *data); +static dynamicPtr *newDynamic (int initialSize, void *data, int freeOKFlag); static int dynamicPutbuf (struct gdIOCtx *, const void *, int); static void dynamicPutchar (struct gdIOCtx *, int a); @@ -63,12 +64,17 @@ /* return data as a dynamic pointer */ gdIOCtx * gdNewDynamicCtx (int initialSize, void *data) { + return gdNewDynamicCtxEx(initialSize, data, 1); +} + +gdIOCtx * gdNewDynamicCtxEx (int initialSize, void *data, int freeOKFlag) +{ dpIOCtx *ctx; dynamicPtr *dp; ctx = (dpIOCtx *) gdMalloc (sizeof (dpIOCtx)); - dp = newDynamic(initialSize, data); + dp = newDynamic(initialSize, data, freeOKFlag); ctx->dp = dp; @@ -103,7 +109,7 @@ } else { *size = 0; data = NULL; - if (dp->data != NULL) { + if (dp->data != NULL && dp->freeOK) { gdFree(dp->data); } } @@ -155,6 +161,10 @@ bytesNeeded = pos; if (bytesNeeded > dp->realSize) { + /* 2.0.21 */ + if (!dp->freeOK) { + return FALSE; + } gdReallocDynamic (dp, dp->realSize * 2); } @@ -171,7 +181,7 @@ } /* return data as a dynamic pointer */ -static dynamicPtr * newDynamic (int initialSize, void *data) +static dynamicPtr * newDynamic (int initialSize, void *data, int freeOKFlag) { dynamicPtr *dp; dp = (dynamicPtr *) gdMalloc (sizeof (dynamicPtr)); @@ -179,6 +189,7 @@ allocDynamic (dp, initialSize, data); dp->pos = 0; + dp->freeOK = freeOKFlag; return dp; } @@ -292,6 +303,10 @@ bytesNeeded = dp->pos + size; if (bytesNeeded > dp->realSize) { + /* 2.0.21 */ + if (!dp->freeOK) { + return FALSE; + } gdReallocDynamic(dp, bytesNeeded * 2); } @@ -337,5 +352,9 @@ /* trim pointer so that its real and logical sizes match */ static int trimDynamic (dynamicPtr * dp) { + /* 2.0.21: we don't reallocate memory we don't own */ + if (!dp->freeOK) { + return FALSE; + } return gdReallocDynamic(dp, dp->logicalSize); } http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd_jpeg.c?r1=1.17&r2=1.18&ty=u Index: php-src/ext/gd/libgd/gd_jpeg.c diff -u php-src/ext/gd/libgd/gd_jpeg.c:1.17 php-src/ext/gd/libgd/gd_jpeg.c:1.18 --- php-src/ext/gd/libgd/gd_jpeg.c:1.17 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd_jpeg.c Mon Mar 29 13:20:33 2004 @@ -217,8 +217,20 @@ return im; } +gdImagePtr gdImageCreateFromJpegPtr (int size, void *data) +{ + gdImagePtr im; + gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0); + im = gdImageCreateFromJpegCtx(in); + in->gd_free(in); + + return im; +} + void jpeg_gdIOCtx_src (j_decompress_ptr cinfo, gdIOCtx * infile); +static int CMYKToRGB(int c, int m, int y, int k, int inverted); + /* * Create a gd-format image from the JPEG-format INFILE. Returns the * image, or NULL upon error. @@ -235,6 +247,8 @@ unsigned int i, j; int retval; JDIMENSION nrows; + int channels = 3; + int inverted = 0; memset (&cinfo, 0, sizeof (cinfo)); memset (&jerr, 0, sizeof (jerr)); @@ -258,6 +272,9 @@ jpeg_gdIOCtx_src (&cinfo, infile); + /* 2.0.22: save the APP14 marker to check for Adobe Photoshop CMYK files with inverted components. */ + jpeg_save_markers(&cinfo, JPEG_APP0 + 14, 256); + retval = jpeg_read_header (&cinfo, TRUE); if (retval != JPEG_HEADER_OK) { php_gd_error_ex(E_WARNING, "gd-jpeg: warning: jpeg_read_header returned %d, expected %d", retval, JPEG_HEADER_OK); @@ -277,8 +294,14 @@ goto error; } - /* Force the image into RGB colorspace, but don't reduce the number of colors anymore (GD 2.0) */ - cinfo.out_color_space = JCS_RGB; + /* 2.0.22: very basic support for reading CMYK colorspace files. Nice for + * thumbnails but there's no support for fussy adjustment of the + * assumed properties of inks and paper. */ + if ((cinfo.jpeg_color_space == JCS_CMYK) || (cinfo.jpeg_color_space == JCS_YCCK)) { + cinfo.out_color_space = JCS_CMYK; + } else { + cinfo.out_color_space = JCS_RGB; + } if (jpeg_start_decompress (&cinfo) != TRUE) { php_gd_error("gd-jpeg: warning: jpeg_start_decompress reports suspended data source"); @@ -297,8 +320,29 @@ gdImageInterlace (im, cinfo.progressive_mode != 0); #endif - if (cinfo.output_components != 3) { - php_gd_error_ex(E_WARNING, "gd-jpeg: error: JPEG color quantization request resulted in output_components == %d (expected 3)", cinfo.output_components); + if (cinfo.out_color_space == JCS_RGB) { + if (cinfo.output_components != 3) { + php_gd_error_ex(E_WARNING, "gd-jpeg: error: JPEG color quantization request resulted in output_components == %d (expected 3 for RGB)", cinfo.output_components); + goto error; + } + channels = 3; + } else if (cinfo.out_color_space == JCS_CMYK) { + jpeg_saved_marker_ptr marker; + if (cinfo.output_components != 4) { + php_gd_error_ex(E_WARNING, "gd-jpeg: error: JPEG color quantization request resulted in output_components == %d (expected 4 for CMYK)", cinfo.output_components); + goto error; + } + channels = 4; + marker = cinfo.marker_list; + while (marker) { + if ((marker->marker == (JPEG_APP0 + 14)) && (marker->data_length >= 12) && (!strncmp((const char *) marker->data, "Adobe", 5))) { + inverted = 1; + break; + } + marker = marker->next; + } + } else { + php_gd_error_ex(E_WARNING, "gd-jpeg: error: unexpected colorspace."); goto error; } @@ -307,22 +351,37 @@ goto error; #endif /* BITS_IN_JSAMPLE == 12 */ - row = safe_emalloc(cinfo.output_width * 3, sizeof(JSAMPLE), 0); - memset(row, 0, cinfo.output_width * 3 * sizeof(JSAMPLE)); + row = safe_emalloc(cinfo.output_width * channels, sizeof(JSAMPLE), 0); + memset(row, 0, cinfo.output_width * channels * sizeof(JSAMPLE)); rowptr[0] = row; - for (i = 0; i < cinfo.output_height; i++) { - register JSAMPROW currow = row; - register int *tpix = im->tpixels[i]; - nrows = jpeg_read_scanlines (&cinfo, rowptr, 1); - if (nrows != 1) { - php_gd_error_ex(E_WARNING, "gd-jpeg: error: jpeg_read_scanlines returns %u, expected 1", nrows); - goto error; + if (cinfo.out_color_space == JCS_CMYK) { + for (i = 0; i < cinfo.output_height; i++) { + register JSAMPROW currow = row; + register int *tpix = im->tpixels[i]; + nrows = jpeg_read_scanlines (&cinfo, rowptr, 1); + if (nrows != 1) { + php_gd_error_ex(E_WARNING, "gd-jpeg: error: jpeg_read_scanlines returns %u, expected 1", nrows); + goto error; + } + for (j = 0; j < cinfo.output_width; j++, currow += 4, tpix++) { + *tpix = CMYKToRGB (currow[0], currow[1], currow[2], currow[3], inverted); + } } - for (j = 0; j < cinfo.output_width; j++, currow += 3, tpix++) { - *tpix = gdTrueColor (currow[0], currow[1], currow[2]); + } else { + for (i = 0; i < cinfo.output_height; i++) { + register JSAMPROW currow = row; + register int *tpix = im->tpixels[i]; + nrows = jpeg_read_scanlines (&cinfo, rowptr, 1); + if (nrows != 1) { + php_gd_error_ex(E_WARNING, "gd-jpeg: error: jpeg_read_scanlines returns %u, expected 1", nrows); + goto error; + } + for (j = 0; j < cinfo.output_width; j++, currow += 3, tpix++) { + *tpix = gdTrueColor (currow[0], currow[1], currow[2]); + } } - } + } if (jpeg_finish_decompress (&cinfo) != TRUE) { php_gd_error("gd-jpeg: warning: jpeg_finish_decompress reports suspended data source"); @@ -349,8 +408,19 @@ return 0; } -/* +/* A very basic conversion approach, TBB */ +static int CMYKToRGB(int c, int m, int y, int k, int inverted) +{ + if (inverted) { + c = 255 - c; + m = 255 - m; + y = 255 - y; + k = 255 - k; + } + return gdTrueColor((255 - c) * (255 - k) / 255, (255 - m) * (255 - k) / 255, (255 - y) * (255 - k) / 255); +} +/* * gdIOCtx JPEG data sources and sinks, T. Boutell * almost a simple global replace from T. Lane's stdio versions. * http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd_png.c?r1=1.16&r2=1.17&ty=u Index: php-src/ext/gd/libgd/gd_png.c diff -u php-src/ext/gd/libgd/gd_png.c:1.16 php-src/ext/gd/libgd/gd_png.c:1.17 --- php-src/ext/gd/libgd/gd_png.c:1.16 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd_png.c Mon Mar 29 13:20:33 2004 @@ -93,6 +93,14 @@ return im; } +gdImagePtr gdImageCreateFromPngPtr (int size, void *data) +{ + gdImagePtr im; + gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0); + im = gdImageCreateFromPngCtx(in); + in->gd_free(in); + return im; +} /* This routine is based in part on the Chapter 13 demo code in "PNG: The * Definitive Guide" (http://www.cdrom.com/pub/png/pngbook.html). http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd_wbmp.c?r1=1.7&r2=1.8&ty=u Index: php-src/ext/gd/libgd/gd_wbmp.c diff -u php-src/ext/gd/libgd/gd_wbmp.c:1.7 php-src/ext/gd/libgd/gd_wbmp.c:1.8 --- php-src/ext/gd/libgd/gd_wbmp.c:1.7 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd_wbmp.c Mon Mar 29 13:20:33 2004 @@ -176,6 +176,15 @@ return im; } +gdImagePtr gdImageCreateFromWBMPPtr (int size, void *data) +{ + gdImagePtr im; + gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0); + im = gdImageCreateFromWBMPCtx(in); + in->gd_free(in); + return im; +} + /* gdImageWBMP ** ----------- */ http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontg.c?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontg.c diff -u php-src/ext/gd/libgd/gdfontg.c:1.1 php-src/ext/gd/libgd/gdfontg.c:1.2 --- php-src/ext/gd/libgd/gdfontg.c:1.1 Fri Apr 12 22:03:08 2002 +++ php-src/ext/gd/libgd/gdfontg.c Mon Mar 29 13:20:33 2004 @@ -4381,4 +4381,9 @@ gdFontPtr gdFontGiant = &gdFontGiantRep; +gdFontPtr gdFontGetGiant(void) +{ + return gdFontGiant; +} + /* This file has not been truncated. */ http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontg.h?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontg.h diff -u php-src/ext/gd/libgd/gdfontg.h:1.1 php-src/ext/gd/libgd/gdfontg.h:1.2 --- php-src/ext/gd/libgd/gdfontg.h:1.1 Fri Apr 12 22:03:08 2002 +++ php-src/ext/gd/libgd/gdfontg.h Mon Mar 29 13:20:33 2004 @@ -20,6 +20,7 @@ #include "gd.h" extern gdFontPtr gdFontGiant; +extern gdFontPtr gdFontGetGiant(void); #ifdef __cplusplus } http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontl.c?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontl.c diff -u php-src/ext/gd/libgd/gdfontl.c:1.1 php-src/ext/gd/libgd/gdfontl.c:1.2 --- php-src/ext/gd/libgd/gdfontl.c:1.1 Fri Apr 12 22:03:08 2002 +++ php-src/ext/gd/libgd/gdfontl.c Mon Mar 29 13:20:33 2004 @@ -4638,4 +4638,9 @@ gdFontPtr gdFontLarge = &gdFontLargeRep; +gdFontPtr gdFontGetLarge(void) +{ + return gdFontLarge; +} + /* This file has not been truncated. */ http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontl.h?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontl.h diff -u php-src/ext/gd/libgd/gdfontl.h:1.1 php-src/ext/gd/libgd/gdfontl.h:1.2 --- php-src/ext/gd/libgd/gdfontl.h:1.1 Fri Apr 12 22:03:08 2002 +++ php-src/ext/gd/libgd/gdfontl.h Mon Mar 29 13:20:33 2004 @@ -21,6 +21,7 @@ #include "gd.h" extern gdFontPtr gdFontLarge; +extern gdFontPtr gdFontGetLarge(void); #ifdef __cplusplus } http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontmb.c?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontmb.c diff -u php-src/ext/gd/libgd/gdfontmb.c:1.1 php-src/ext/gd/libgd/gdfontmb.c:1.2 --- php-src/ext/gd/libgd/gdfontmb.c:1.1 Fri Apr 12 22:03:08 2002 +++ php-src/ext/gd/libgd/gdfontmb.c Mon Mar 29 13:20:33 2004 @@ -3868,4 +3868,9 @@ gdFontPtr gdFontMediumBold = &gdFontMediumBoldRep; +gdFontPtr gdFontGetMediumBold(void) +{ + return gdFontMediumBold; +} + /* This file has not been truncated. */ http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontmb.h?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontmb.h diff -u php-src/ext/gd/libgd/gdfontmb.h:1.1 php-src/ext/gd/libgd/gdfontmb.h:1.2 --- php-src/ext/gd/libgd/gdfontmb.h:1.1 Fri Apr 12 22:03:08 2002 +++ php-src/ext/gd/libgd/gdfontmb.h Mon Mar 29 13:20:33 2004 @@ -19,6 +19,7 @@ #include "gd.h" extern gdFontPtr gdFontMediumBold; +extern gdFontPtr gdFontGetMediumBold(void); #ifdef __cplusplus } http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfonts.c?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfonts.c diff -u php-src/ext/gd/libgd/gdfonts.c:1.1 php-src/ext/gd/libgd/gdfonts.c:1.2 --- php-src/ext/gd/libgd/gdfonts.c:1.1 Fri Apr 12 22:03:09 2002 +++ php-src/ext/gd/libgd/gdfonts.c Mon Mar 29 13:20:33 2004 @@ -3868,4 +3868,9 @@ gdFontPtr gdFontSmall = &gdFontSmallRep; +gdFontPtr gdFontGetSmall(void) +{ + return gdFontSmall; +} + /* This file has not been truncated. */ http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfonts.h?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfonts.h diff -u php-src/ext/gd/libgd/gdfonts.h:1.1 php-src/ext/gd/libgd/gdfonts.h:1.2 --- php-src/ext/gd/libgd/gdfonts.h:1.1 Fri Apr 12 22:03:09 2002 +++ php-src/ext/gd/libgd/gdfonts.h Mon Mar 29 13:20:33 2004 @@ -19,6 +19,7 @@ #include "gd.h" extern gdFontPtr gdFontSmall; +extern gdFontPtr gdFontGetSmall(void); #ifdef __cplusplus } http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontt.c?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontt.c diff -u php-src/ext/gd/libgd/gdfontt.c:1.1 php-src/ext/gd/libgd/gdfontt.c:1.2 --- php-src/ext/gd/libgd/gdfontt.c:1.1 Fri Apr 12 22:03:09 2002 +++ php-src/ext/gd/libgd/gdfontt.c Mon Mar 29 13:20:33 2004 @@ -2589,4 +2589,9 @@ gdFontPtr gdFontTiny = &gdFontTinyRep; +gdFontPtr gdFontGetTiny(void) +{ + return gdFontTiny; +} + /* This file has not been truncated. */ http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdfontt.h?r1=1.1&r2=1.2&ty=u Index: php-src/ext/gd/libgd/gdfontt.h diff -u php-src/ext/gd/libgd/gdfontt.h:1.1 php-src/ext/gd/libgd/gdfontt.h:1.2 --- php-src/ext/gd/libgd/gdfontt.h:1.1 Fri Apr 12 22:03:09 2002 +++ php-src/ext/gd/libgd/gdfontt.h Mon Mar 29 13:20:33 2004 @@ -20,6 +20,7 @@ #include "gd.h" extern gdFontPtr gdFontTiny; +extern gdFontPtr gdFontGetTiny(void); #ifdef __cplusplus } http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gdft.c?r1=1.32&r2=1.33&ty=u Index: php-src/ext/gd/libgd/gdft.c diff -u php-src/ext/gd/libgd/gdft.c:1.32 php-src/ext/gd/libgd/gdft.c:1.33 --- php-src/ext/gd/libgd/gdft.c:1.32 Sat Mar 6 13:24:41 2004 +++ php-src/ext/gd/libgd/gdft.c Mon Mar 29 13:20:33 2004 @@ -80,9 +80,9 @@ /* * The character (space) used to separate alternate fonts in the - * fontlist parameter to gdImageStringFT. + * fontlist parameter to gdImageStringFT. 2.0.18: space was a oor choice for this. */ -#define LISTSEPARATOR " " +#define LISTSEPARATOR ";" /* * DEFAULT_FONTPATH and PATHSEPARATOR are host type dependent and @@ -434,7 +434,7 @@ encoding = charmap->encoding_id; /* EAM DEBUG - Newer versions of libfree2 make it easier by defining encodings */ -#ifdef FT_ENCODING_MS_SYMBOL +#if (defined(FREETYPE_MAJOR) && (FREETYPE_MAJOR >=2 ) && (FREETYPE_MINOR >= 1)) if (charmap->encoding == FT_ENCODING_MS_SYMBOL || charmap->encoding == FT_ENCODING_ADOBE_CUSTOM || charmap->encoding == FT_ENCODING_ADOBE_STANDARD) { @@ -443,7 +443,7 @@ a->face->charmap = charmap; return (void *)a; } -#endif /* FT_ENCODING_MS_SYMBOL */ +#endif /* Freetype 2.1 or better */ /* EAM DEBUG */ if ((platform == 3 && encoding == 1) /* Windows Unicode */ @@ -707,6 +707,11 @@ } } +void gdFreeFontCache() +{ + gdFontCacheShutdown(); +} + int gdFontCacheSetup(void) { if (fontCache) { @@ -895,7 +900,7 @@ } /* EAM DEBUG */ -#ifdef FT_ENCODING_MS_SYMBOL +#if (defined(FREETYPE_MAJOR) && (FREETYPE_MAJOR >=2 ) && (FREETYPE_MINOR >= 1)) if (font->face->charmap->encoding == FT_ENCODING_MS_SYMBOL) { /* I do not know the significance of the constant 0xf000. * It was determined by inspection of the character codes @@ -905,7 +910,7 @@ ch |= 0xf000; next += len; } else -#endif /* FT_ENCODING_MS_SYMBOL */ +#endif /* Freetype 2.1 or better */ /* EAM DEBUG */ switch (m) {