Browse Source

Syncronized bunbled GD library with gd 2.0.12

# One very useful feature that I still need to add support for in our
# interface to the lib is the support for png compression for imagepng().
migration/unlabaled-1.3.2
Ilia Alshanetsky 23 years ago
parent
commit
61026e391c
  1. 2570
      ext/gd/libgd/gd.c
  2. 59
      ext/gd/libgd/gd.h
  3. 111
      ext/gd/libgd/gd_gd.c
  4. 8
      ext/gd/libgd/gd_gd2.c
  5. 4
      ext/gd/libgd/gd_io.h
  6. 68
      ext/gd/libgd/gd_jpeg.c
  7. 38
      ext/gd/libgd/gd_png.c
  8. 2537
      ext/gd/libgd/gd_topal.c
  9. 2
      ext/gd/libgd/gdcache.c
  10. 2
      ext/gd/libgd/gdcache.h
  11. 144
      ext/gd/libgd/gdft.c
  12. 3
      ext/gd/libgd/gdkanji.c

2570
ext/gd/libgd/gd.c
File diff suppressed because it is too large
View File

59
ext/gd/libgd/gd.h

@ -147,6 +147,31 @@ typedef struct gdImageStruct {
PNG at the moment; other future formats may also
have that capability. JPEG doesn't. */
int saveAlphaFlag;
/* 2.0.12: anti-aliased globals */
int AA;
int AA_color;
int AA_dont_blend;
unsigned char **AA_opacity;
int AA_polygon;
/* Stored and pre-computed variables for determining the perpendicular
* distance from a point to the anti-aliased line being drawn:
*/
int AAL_x1;
int AAL_y1;
int AAL_x2;
int AAL_y2;
int AAL_Bx_Ax;
int AAL_By_Ay;
int AAL_LAB_2;
float AAL_LAB;
/* 2.0.12: simple clipping rectangle. These values must be checked for safety when set; please use gdImageSetClip */
int cx1;
int cy1;
int cx2;
int cy2;
} gdImage;
typedef gdImage * gdImagePtr;
@ -184,6 +209,8 @@ typedef gdFont *gdFontPtr;
This is used in line styles only. */
#define gdTransparent (-6)
#define gdAntiAliased (-7)
/* Functions to manipulate images. */
/* Creates a palette-based image (up to 256 colors). */
@ -245,6 +272,8 @@ void gdImageSetPixel(gdImagePtr im, int x, int y, int color);
int gdImageGetPixel(gdImagePtr im, int x, int y);
void gdImageAABlend(gdImagePtr im);
void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
void gdImageAALine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
@ -256,6 +285,8 @@ void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color)
void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
/* Solid bar. Upper left corner first, lower right corner second. */
void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
void gdImageSetClip(gdImagePtr im, int x1, int y1, int x2, int y2);
void gdImageGetClip(gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P);
void gdImageChar(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
void gdImageCharUp(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
@ -275,10 +306,22 @@ char *gdImageStringFT(gdImage *im, int *brect, int fg, char *fontlist,
double ptsize, double angle, int x, int y, char *string);
typedef struct {
int flags; /* for future expansion logical OR of gdFTEX_ values */
double linespacing; /* fine tune line spacing for '\n' */
} gdFTStringExtra, *gdFTStringExtraPtr;
double linespacing; /* fine tune line spacing for '\n' */
int flags; /* Logical OR of gdFTEX_ values */
int charmap; /* TBB: 2.0.12: may be gdFTEX_Unicode,
gdFTEX_Shift_JIS, or gdFTEX_Big5;
when not specified, maps are searched
for in the above order. */
}
gdFTStringExtra, *gdFTStringExtraPtr;
#define gdFTEX_LINESPACE 1
#define gdFTEX_CHARMAP 2
/* These are NOT flags; set one in 'charmap' if you set the gdFTEX_CHARMAP bit in 'flags'. */
#define gdFTEX_Unicode 0
#define gdFTEX_Shift_JIS 1
#define gdFTEX_Big5 2
/* FreeType 2 text output with fine tuning */
char *
@ -373,6 +416,13 @@ void gdImageColorTransparent(gdImagePtr im, int color);
void gdImagePaletteCopy(gdImagePtr dst, gdImagePtr src);
void gdImagePng(gdImagePtr im, FILE *out);
void gdImagePngCtx(gdImagePtr im, gdIOCtx *out);
/* 2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all,
* 1 is FASTEST but produces larger files, 9 provides the best
* compression (smallest files) but takes a long time to compress, and
* -1 selects the default compiled into the zlib library.
*/
void gdImagePngEx(gdImagePtr im, FILE * out, int level);
void gdImagePngCtxEx(gdImagePtr im, gdIOCtx * out, int level);
void gdImageWBMP(gdImagePtr image, int fg, FILE *out);
void gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out);
@ -416,6 +466,7 @@ void* gdImagePngPtr(gdImagePtr im, int *size);
/* Best to free this memory with gdFree(), not free() */
void* gdImageGdPtr(gdImagePtr im, int *size);
void *gdImagePngPtrEx(gdImagePtr im, int *size, int level);
/* Best to free this memory with gdFree(), not free() */
void* gdImageGd2Ptr(gdImagePtr im, int cs, int fmt, int *size);
@ -474,6 +525,8 @@ gdImagePtr gdImageRotate (gdImagePtr src, double dAngle, int clrBack);
void gdImageSetBrush(gdImagePtr im, gdImagePtr brush);
void gdImageSetTile(gdImagePtr im, gdImagePtr tile);
void gdImageSetAntiAliased(gdImagePtr im, int c);
void gdImageSetAntiAliasedDontBlend(gdImagePtr im, int c, int dont_blend);
void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels);
/* Line thickness (defaults to 1). Affects lines, ellipses,
rectangles, polygons and so forth. */

111
ext/gd/libgd/gd_gd.c

@ -23,13 +23,23 @@ int _gdGetColors (gdIOCtx * in, gdImagePtr im, int gd2xFlag)
{
int i;
if (gd2xFlag) {
if (!gdGetByte (&im->trueColor, in)) {
int trueColorFlag;
if (!gdGetByte(&trueColorFlag, in)) {
goto fail1;
}
/* This should have been a word all along */
if (!im->trueColor && !gdGetWord(&im->colorsTotal, in)) {
/* 2.0.12: detect bad truecolor .gd files created by pre-2.0.12.
* Beginning in 2.0.12 truecolor is indicated by the initial 2-byte
* signature.
*/
if (trueColorFlag != im->trueColor) {
goto fail1;
}
/* This should have been a word all along */
if (!im->trueColor) {
if (!gdGetWord(&im->colorsTotal, in)) {
goto fail1;
}
}
/* Int to accommodate truecolor single-color transparency */
if (!gdGetInt(&im->transparent, in)) {
goto fail1;
@ -38,14 +48,19 @@ int _gdGetColors (gdIOCtx * in, gdImagePtr im, int gd2xFlag)
if (!gdGetByte(&im->colorsTotal, in)) {
goto fail1;
}
if (!gdGetWord (&im->transparent, in)) {
if (!gdGetWord(&im->transparent, in)) {
goto fail1;
}
if (im->transparent == 257) {
im->transparent = (-1);
}
}
GD2_DBG (php_gd_error("Pallette had %d colours (T=%d)\n", im->colorsTotal, im->transparent));
GD2_DBG(printf("Pallette had %d colours (T=%d)\n", im->colorsTotal, im->transparent));
if (im->trueColor) {
return TRUE;
}
for (i = 0; i < gdMaxColors; i++) {
if (!gdGetByte(&im->red[i], in)) {
@ -57,12 +72,14 @@ int _gdGetColors (gdIOCtx * in, gdImagePtr im, int gd2xFlag)
if (!gdGetByte(&im->blue[i], in)) {
goto fail1;
}
if (gd2xFlag && !gdGetByte (&im->alpha[i], in)) {
goto fail1;
if (gd2xFlag) {
if (!gdGetByte(&im->alpha[i], in)) {
goto fail1;
}
}
}
for (i = 0; (i < im->colorsTotal); i++) {
for (i = 0; i < im->colorsTotal; i++) {
im->open[i] = 0;
}
@ -73,18 +90,23 @@ fail1:
/* */
/* Use the common basic header info to make the image object. */
/* This is also called from _gd2CreateFromFile */
/* */
static gdImagePtr _gdCreateFromFile (gdIOCtx * in, int *sx, int *sy)
{
gdImagePtr im;
int gd2xFlag = 0;
int trueColorFlag = 0;
if (!gdGetWord(sx, in)) {
goto fail1;
}
if (*sx == 65535) {
if (*sx == 65535 || *sx == 65534) {
/* This is a gd 2.0 .gd file */
gd2xFlag = 1;
/* 2.0.12: 65534 signals a truecolor .gd file. There is a slight redundancy here but we can live with it. */
if (*sx == 65534) {
trueColorFlag = 1;
}
if (!gdGetWord(sx, in)) {
goto fail1;
}
@ -93,10 +115,13 @@ static gdImagePtr _gdCreateFromFile (gdIOCtx * in, int *sx, int *sy)
goto fail1;
}
GD2_DBG(php_gd_error("Image is %dx%d\n", *sx, *sy));
im = gdImageCreate (*sx, *sy);
GD2_DBG(printf("Image is %dx%d\n", *sx, *sy));
if (trueColorFlag) {
im = gdImageCreateTrueColor(*sx, *sy);
} else {
im = gdImageCreate(*sx, *sy);
}
if (!_gdGetColors(in, im, gd2xFlag)) {
goto fail2;
}
@ -113,8 +138,8 @@ gdImagePtr gdImageCreateFromGd (FILE * inFile)
gdImagePtr im;
gdIOCtx *in;
in = gdNewFileCtx (inFile);
im = gdImageCreateFromGdCtx (in);
in = gdNewFileCtx(inFile);
im = gdImageCreateFromGdCtx(in);
in->gd_free(in);
@ -128,19 +153,35 @@ gdImagePtr gdImageCreateFromGdCtx (gdIOCtxPtr in)
gdImagePtr im;
/* Read the header */
if ((im = _gdCreateFromFile (in, &sx, &sy)) == NULL) {
im = _gdCreateFromFile(in, &sx, &sy);
if (im == NULL) {
goto fail1;
}
/* Then the data... */
for (y = 0; y < sy; y++) {
for (x = 0; x < sx; x++) {
int ch;
if ((ch = gdGetC(in)) == EOF) {
goto fail2;
/* 2.0.12: support truecolor properly in .gd as well as in .gd2. Problem reported by Andreas Pfaller. */
if (im->trueColor) {
for (y = 0; y < sy; y++) {
for (x = 0; x < sx; x++) {
int pix;
if (!gdGetInt(&pix, in)) {
goto fail2;
}
im->tpixels[y][x] = pix;
}
}
} else {
for (y = 0; y < sy; y++) {
for (x = 0; x < sx; x++) {
int ch;
ch = gdGetC(in);
if (ch == EOF) {
goto fail2;
}
/* ROW-MAJOR IN GD 1.3 */
im->pixels[y][x] = ch;
}
/* ROW-MAJOR IN GD 1.3 */
im->pixels[y][x] = ch;
}
}
@ -158,11 +199,11 @@ void _gdPutColors (gdImagePtr im, gdIOCtx * out)
gdPutC(im->trueColor, out);
if (!im->trueColor) {
gdPutWord (im->colorsTotal, out);
gdPutWord(im->colorsTotal, out);
}
gdPutInt (im->transparent, out);
gdPutInt(im->transparent, out);
if (!im->trueColor) {
for (i = 0; (i < gdMaxColors); i++) {
for (i = 0; i < gdMaxColors; i++) {
gdPutC((unsigned char) im->red[i], out);
gdPutC((unsigned char) im->green[i], out);
gdPutC((unsigned char) im->blue[i], out);
@ -173,25 +214,31 @@ void _gdPutColors (gdImagePtr im, gdIOCtx * out)
static void _gdPutHeader (gdImagePtr im, gdIOCtx * out)
{
/* 65535 indicates this is a gd 2.x .gd file. */
gdPutWord(65535, out);
/* 65535 indicates this is a gd 2.x .gd file.
* 2.0.12: 65534 indicates truecolor.
*/
if (im->trueColor) {
gdPutWord(65534, out);
} else {
gdPutWord(65535, out);
}
gdPutWord(im->sx, out);
gdPutWord(im->sy, out);
_gdPutColors (im, out);
_gdPutColors(im, out);
}
static void _gdImageGd (gdImagePtr im, gdIOCtx * out)
{
int x, y;
_gdPutHeader (im, out);
_gdPutHeader(im, out);
for (y = 0; y < im->sy; y++) {
for (x = 0; x < im->sx; x++) {
/* ROW-MAJOR IN GD 1.3 */
if (im->trueColor) {
gdPutInt (im->tpixels[y][x], out);
gdPutInt(im->tpixels[y][x], out);
} else {
gdPutC((unsigned char) im->pixels[y][x], out);
}
@ -206,7 +253,7 @@ void gdImageGd (gdImagePtr im, FILE * outFile)
out->gd_free(out);
}
void * gdImageGdPtr (gdImagePtr im, int *size)
void *gdImageGdPtr (gdImagePtr im, int *size)
{
void *rv;
gdIOCtx *out = gdNewDynamicCtx(2048, NULL);

8
ext/gd/libgd/gd_gd2.c

@ -292,7 +292,7 @@ gdImagePtr gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
if (gd2_compressed(fmt)) {
chunkLen = chunkMax;
if (!_gd2ReadChunk(chunkIdx[chunkNum].offset, compBuf, chunkIdx[chunkNum].size, chunkBuf, &chunkLen, in)) {
if (!_gd2ReadChunk(chunkIdx[chunkNum].offset, compBuf, chunkIdx[chunkNum].size, (char *) chunkBuf, &chunkLen, in)) {
GD2_DBG(php_gd_error("Error reading comproessed chunk\n"));
goto fail2;
}
@ -390,9 +390,11 @@ gdImagePtr gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w,
int x, y, ylo, yhi, xlo, xhi;
int dstart, dpos;
int i;
int ch, vers, fmt;
/* 2.0.12: unsigned is correct; fixes problems with color munging. Thanks to Steven Brown. */
unsigned int ch;
int vers, fmt;
t_chunk_info *chunkIdx = NULL;
char *chunkBuf = NULL;
unsigned char *chunkBuf = NULL;
int chunkNum;
int chunkMax = 0;
uLongf chunkLen;

4
ext/gd/libgd/gd_io.h

@ -2,6 +2,10 @@
#define GD_IO_H 1
#include <stdio.h>
#ifdef VMS
#define Putchar gdPutchar
#endif
typedef struct gdIOCtx {
int (*getC)(struct gdIOCtx*);

68
ext/gd/libgd/gd_jpeg.c

@ -46,8 +46,7 @@ typedef struct _jmpbuf_wrapper
} jmpbuf_wrapper;
/* Called by the IJG JPEG library upon encountering a fatal error */
static void
fatal_jpeg_error (j_common_ptr cinfo)
static void fatal_jpeg_error (j_common_ptr cinfo)
{
jmpbuf_wrapper *jmpbufw;
@ -76,16 +75,14 @@ fatal_jpeg_error (j_common_ptr cinfo)
* library documentation for more details.
*/
void
gdImageJpeg (gdImagePtr im, FILE * outFile, int quality)
void gdImageJpeg (gdImagePtr im, FILE * outFile, int quality)
{
gdIOCtx *out = gdNewFileCtx (outFile);
gdImageJpegCtx (im, out, quality);
out->gd_free (out);
}
void *
gdImageJpegPtr (gdImagePtr im, int *size, int quality)
void *gdImageJpegPtr (gdImagePtr im, int *size, int quality)
{
void *rv;
gdIOCtx *out = gdNewDynamicCtx (2048, NULL);
@ -98,8 +95,7 @@ gdImageJpegPtr (gdImagePtr im, int *size, int quality)
void jpeg_gdIOCtx_dest (j_compress_ptr cinfo, gdIOCtx * outfile);
void
gdImageJpegCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
void gdImageJpegCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
{
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
@ -210,12 +206,11 @@ gdImageJpegCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
gdFree (row);
}
gdImagePtr
gdImageCreateFromJpeg (FILE * inFile)
gdImagePtr gdImageCreateFromJpeg (FILE * inFile)
{
gdImagePtr im;
gdIOCtx *in = gdNewFileCtx (inFile);
im = gdImageCreateFromJpegCtx (in);
gdIOCtx *in = gdNewFileCtx(inFile);
im = gdImageCreateFromJpegCtx(in);
in->gd_free (in);
return im;
@ -227,8 +222,7 @@ void jpeg_gdIOCtx_src (j_decompress_ptr cinfo, gdIOCtx * infile);
* Create a gd-format image from the JPEG-format INFILE. Returns the
* image, or NULL upon error.
*/
gdImagePtr
gdImageCreateFromJpegCtx (gdIOCtx * infile)
gdImagePtr gdImageCreateFromJpegCtx (gdIOCtx * infile)
{
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
@ -388,8 +382,7 @@ typedef my_source_mgr *my_src_ptr;
* before any data is actually read.
*/
void
init_source (j_decompress_ptr cinfo)
void init_source (j_decompress_ptr cinfo)
{
my_src_ptr src = (my_src_ptr) cinfo->src;
@ -436,21 +429,21 @@ init_source (j_decompress_ptr cinfo)
#define END_JPEG_SEQUENCE "\r\n[*]--:END JPEG:--[*]\r\n"
safeboolean
fill_input_buffer (j_decompress_ptr cinfo)
safeboolean fill_input_buffer (j_decompress_ptr cinfo)
{
my_src_ptr src = (my_src_ptr) cinfo->src;
size_t nbytes = 0;
/* size_t got; */
/* 2.0.12: signed size. Thanks to Geert Jansen */
ssize_t nbytes = 0;
/* ssize_t got; */
/* char *s; */
memset (src->buffer, 0, INPUT_BUF_SIZE);
memset(src->buffer, 0, INPUT_BUF_SIZE);
while (nbytes < INPUT_BUF_SIZE) {
int got = gdGetBuf (src->buffer + nbytes, INPUT_BUF_SIZE - nbytes, src->infile);
if ((got == EOF) || (got == 0)) {
/* EOF or error. If we got any data, don't worry about it. If we didn't, then this is unexpected. */
int got = gdGetBuf(src->buffer + nbytes, INPUT_BUF_SIZE - nbytes, src->infile);
if (got == EOF || got == 0) {
/* EOF or error. If we got any data, don't worry about it. If we didn't, then this is unexpected. */
if (!nbytes) {
nbytes = -1;
}
@ -490,8 +483,7 @@ fill_input_buffer (j_decompress_ptr cinfo)
* buffer is the application writer's problem.
*/
void
skip_input_data (j_decompress_ptr cinfo, long num_bytes)
void skip_input_data (j_decompress_ptr cinfo, long num_bytes)
{
my_src_ptr src = (my_src_ptr) cinfo->src;
@ -530,8 +522,7 @@ skip_input_data (j_decompress_ptr cinfo, long num_bytes)
* for error exit.
*/
void
term_source (j_decompress_ptr cinfo)
void term_source (j_decompress_ptr cinfo)
{
#if 0
* never used */
@ -546,8 +537,7 @@ term_source (j_decompress_ptr cinfo)
* for closing it after finishing decompression.
*/
void
jpeg_gdIOCtx_src (j_decompress_ptr cinfo, gdIOCtx * infile)
void jpeg_gdIOCtx_src (j_decompress_ptr cinfo, gdIOCtx * infile)
{
my_src_ptr src;
@ -595,8 +585,7 @@ typedef my_destination_mgr *my_dest_ptr;
* before any data is actually written.
*/
void
init_destination (j_compress_ptr cinfo)
void init_destination (j_compress_ptr cinfo)
{
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
@ -631,8 +620,7 @@ init_destination (j_compress_ptr cinfo)
* write it out when emptying the buffer externally.
*/
safeboolean
empty_output_buffer (j_compress_ptr cinfo)
safeboolean empty_output_buffer (j_compress_ptr cinfo)
{
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
@ -656,8 +644,7 @@ empty_output_buffer (j_compress_ptr cinfo)
* for error exit.
*/
void
term_destination (j_compress_ptr cinfo)
void term_destination (j_compress_ptr cinfo)
{
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
@ -675,8 +662,7 @@ term_destination (j_compress_ptr cinfo)
* for closing it after finishing compression.
*/
void
jpeg_gdIOCtx_dest (j_compress_ptr cinfo, gdIOCtx * outfile)
void jpeg_gdIOCtx_dest (j_compress_ptr cinfo, gdIOCtx * outfile)
{
my_dest_ptr dest;

38
ext/gd/libgd/gd_png.c

@ -295,7 +295,6 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile)
if (!im->trueColor) {
im->colorsTotal = num_palette;
im->transparent = transparent;
/* load the palette and mark all entries "open" (unused) for now */
open = im->open;
for (i = 0; i < num_palette; ++i) {
@ -308,7 +307,10 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile)
open[i] = 1;
}
}
/* 2.0.12: Slaven Rezic: palette images are not the only images
* with a simple transparent color setting.
*/
im->transparent = transparent;
im->interlace = (interlace_type == PNG_INTERLACE_ADAM7);
/* can't nuke structs until done with palette */
@ -374,11 +376,17 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile)
return im;
}
void gdImagePngEx (gdImagePtr im, FILE * outFile, int level)
{
gdIOCtx *out = gdNewFileCtx(outFile);
gdImagePngCtxEx(im, out, level);
out->gd_free(out);
}
void gdImagePng (gdImagePtr im, FILE * outFile)
{
gdIOCtx *out = gdNewFileCtx(outFile);
gdImagePngCtx(im, out);
gdImagePngCtxEx(im, out, -1);
out->gd_free(out);
}
@ -386,18 +394,33 @@ void * gdImagePngPtr (gdImagePtr im, int *size)
{
void *rv;
gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
gdImagePngCtx(im, out);
gdImagePngCtxEx(im, out, -1);
rv = gdDPExtractData(out, size);
out->gd_free(out);
return rv;
}
void * gdImagePngPtrEx (gdImagePtr im, int *size, int level)
{
void *rv;
gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
gdImagePngCtxEx(im, out, level);
rv = gdDPExtractData(out, size);
out->gd_free(out);
return rv;
}
void gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
{
return gdImagePngCtxEx(im, outfile, -1);
}
/* This routine is based in part on code from Dale Lutz (Safe Software Inc.)
* and in part on demo code from Chapter 15 of "PNG: The Definitive Guide"
* (http://www.cdrom.com/pub/png/pngbook.html).
*/
void gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
void gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
{
int i, j, bit_depth = 0, interlace_type;
int width = im->sx;
@ -451,9 +474,8 @@ void gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
/* png_set_filter(png_ptr, 0, PNG_FILTER_NONE); */
/* may want to force maximum compression, but time penalty is large
* png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
*/
/* 2.0.12: this is finally a parameter */
png_set_compression_level(png_ptr, level);
/* can set this to a smaller value without compromising compression if all
* image data is 16K or less; will save some decoder memory [min == 8]

2537
ext/gd/libgd/gd_topal.c
File diff suppressed because it is too large
View File

2
ext/gd/libgd/gdcache.c

@ -18,7 +18,7 @@
* element is replaced in the event of a cache miss after the cache has
* reached a given size.
*
* John Ellson (ellson@lucent.com) Oct 31, 1997
* John Ellson (ellson@graphviz.org) Oct 31, 1997
*
* Test this with:
* gcc -o gdcache -g -Wall -DTEST gdcache.c

2
ext/gd/libgd/gdcache.h

@ -5,7 +5,7 @@
* element is replaced in the event of a cache miss after the cache has
* reached a given size.
*
* John Ellson (ellson@lucent.com) Oct 31, 1997
* John Ellson (ellson@graphviz.org) Oct 31, 1997
*
* Test this with:
* gcc -o gdcache -g -Wall -DTEST gdcache.c

144
ext/gd/libgd/gdft.c

@ -2,7 +2,7 @@
/********************************************/
/* gd interface to freetype library */
/* */
/* John Ellson ellson@lucent.com */
/* John Ellson ellson@graphviz.org */
/********************************************/
#include <stdio.h>
@ -16,6 +16,7 @@
#include <unistd.h>
#else
#include <io.h>
#define R_OK 04 /* Needed in Windows */
#endif
#ifdef WIN32
@ -83,7 +84,7 @@ gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
/*
* DEFAULT_FONTPATH and PATHSEPARATOR are host type dependent and
* are normally set by configure in gvconfig.h. These are just
* are normally set by configure in config.h. These are just
* some last resort values that might match some Un*x system
* if building this version of gd separate from graphviz.
*/
@ -789,6 +790,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
int render = (im && (im->trueColor || (fg <= 255 && fg >= -255)));
FT_BitmapGlyph bm;
int render_mode = FT_LOAD_RENDER | FT_LOAD_FORCE_AUTOHINT;
int m, mfound;
/* Now tuneable thanks to Wez Furlong */
double linespace = LINESPACE;
/* 2.0.6: put this declaration with the other declarations! */
@ -847,13 +849,49 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
if (fg < 0) {
render_mode |= FT_LOAD_MONOCHROME;
}
/* 2.0.12: allow explicit specification of the preferred map;
* but we still fall back if it is not available.
*/
m = gdFTEX_Unicode;
if (strex && (strex->flags & gdFTEX_CHARMAP)) {
m = strex->charmap;
}
/* Try all three types of maps, but start with the specified one */
mfound = 0;
for (i = 0; i < 3; i++) {
switch (m) {
case gdFTEX_Unicode:
if (font->have_char_map_unicode) {
mfound = 1;
}
break;
case gdFTEX_Shift_JIS:
if (font->have_char_map_sjis) {
mfound = 1;
}
break;
case gdFTEX_Big5:
/* This was the 'else' case, we can't really 'detect' it */
mfound = 1;
break;
}
if (mfound) {
break;
}
m++;
m %= 3;
}
if (!mfound) {
/* No character set found! */
return "No character set found";
}
#ifndef JISX0208
if (!font->have_char_map_sjis) {
next = string;
} else
#endif
tmpstr = (char *) gdMalloc (BUFSIZ);
tmpstr = (char *) gdMalloc(BUFSIZ);
while (*next) {
ch = *next;
@ -879,57 +917,65 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
next++;
continue;
}
if (font->have_char_map_unicode) {
/* use UTF-8 mapping from ASCII */
len = gdTcl_UtfToUniChar (next, &ch);
next += len;
} else if (font->have_char_map_sjis) {
unsigned char c;
int jiscode;
c = *next;
if (0xA1 <= c && c <= 0xFE) {
next++;
jiscode = 0x100 * (c & 0x7F) + ((*next) & 0x7F);
ch = (jiscode >> 8) & 0xFF;
jiscode &= 0xFF;
if (ch & 1) {
jiscode += 0x40 - 0x21;
} else {
jiscode += 0x9E - 0x21;
}
if (jiscode >= 0x7F) {
jiscode++;
switch (m) {
case gdFTEX_Unicode:
if (font->have_char_map_unicode) {
/* use UTF-8 mapping from ASCII */
len = gdTcl_UtfToUniChar(next, &ch);
next += len;
}
ch = (ch - 0x21) / 2 + 0x81;
if (ch >= 0xA0) {
ch += 0x40;
break;
case gdFTEX_Shift_JIS:
if (font->have_char_map_sjis) {
unsigned char c;
int jiscode;
c = *next;
if (0xA1 <= c && c <= 0xFE) {
next++;
jiscode = 0x100 * (c & 0x7F) + ((*next) & 0x7F);
ch = (jiscode >> 8) & 0xFF;
jiscode &= 0xFF;
if (ch & 1) {
jiscode += 0x40 - 0x21;
} else {
jiscode += 0x9E - 0x21;
}
if (jiscode >= 0x7F) {
jiscode++;
}
ch = (ch - 0x21) / 2 + 0x81;
if (ch >= 0xA0) {
ch += 0x40;
}
ch = (ch << 8) + jiscode;
} else {
ch = c & 0xFF; /* don't extend sign */
}
next++;
}
ch = (ch << 8) + jiscode;
} else {
ch = c & 0xFF; /* don't extend sign */
}
next++;
} else {
/*
* Big 5 mapping:
* use "JIS-8 half-width katakana" coding from 8-bit characters. Ref:
* ftp://ftp.ora.com/pub/examples/nutshell/ujip/doc/japan.inf-032092.sjs
*/
ch = (*next) & 0xFF; /* don't extend sign */
next++;
/* first code of JIS-8 pair */
if (ch >= 161 && *next) { /* don't advance past '\0' */
/* TBB: Fix from Kwok Wah On: & 255 needed */
ch = (ch * 256) + ((*next) & 255);
break;
case gdFTEX_Big5: {
/*
* Big 5 mapping:
* use "JIS-8 half-width katakana" coding from 8-bit characters. Ref:
* ftp://ftp.ora.com/pub/examples/nutshell/ujip/doc/japan.inf-032092.sjs
*/
ch = (*next) & 0xFF; /* don't extend sign */
next++;
if (ch >= 161 /* first code of JIS-8 pair */
&& *next) { /* don't advance past '\0' */
/* TBB: Fix from Kwok Wah On: & 255 needed */
ch = (ch * 256) + ((*next) & 255);
next++;
}
}
break;
}
/* set rotation transform */
FT_Set_Transform(face, &matrix, NULL);
/* Convert character code to glyph index */

3
ext/gd/libgd/gdkanji.c

@ -362,8 +362,7 @@ do_convert (unsigned char *to, unsigned char *from, const char *code)
from_len = strlen ((const char *) from) + 1;
to_len = BUFSIZ;
if (iconv (cd, (char **) &from, &from_len,
(char **) &to, &to_len) == -1)
if ((int) iconv(cd, (char **) &from, &from_len, (char **) &to, &to_len) == -1)
{
#ifdef HAVE_ERRNO_H
if (errno == EINVAL)

Loading…
Cancel
Save