- sync to 1.8.4
parent
dd92c2b0df
commit
22d55c5aa4
51
src/Makefile
51
src/Makefile
|
@ -10,37 +10,42 @@ COMPILER=gcc
|
|||
AR=ar
|
||||
|
||||
#If you don't have FreeType, libjpeg and/or Xpm installed, including the
|
||||
#header files, uncomment this (default).
|
||||
CFLAGS=-O
|
||||
#header files, uncomment this (default). You really must install
|
||||
#libpng and zlib to get anywhere if you wish to create PNG images.
|
||||
CFLAGS=-O -DHAVE_LIBPNG -DHAVE_LIBJPEG
|
||||
|
||||
#If you do have FreeType, libjpeg and/or Xpm fully installed, uncomment a
|
||||
#variation of this and comment out the line above. See also LIBS below.
|
||||
#CFLAGS=-O -DHAVE_XPM -DHAVE_JPEG -DHAVE_LIBTTF
|
||||
#CFLAGS=-O -DHAVE_LIBXPM -DHAVE_LIBPNG -DHAVE_LIBJPEG \
|
||||
# -DHAVE_LIBFREETYPE -DHAVE_LIBTTF
|
||||
|
||||
#If you don't have FreeType and/or Xpm fully installed, uncomment this
|
||||
#To use the old FreeType 1.x library, add this additional #define
|
||||
#to the line above
|
||||
#-DHAVE_LIBTTF
|
||||
|
||||
#If you don't have FreeType Xpm fully installed, uncomment this
|
||||
#(default).
|
||||
|
||||
#PLEASE NOTE: YOU MAY HAVE TO JUGGLE THE ORDER OF THE LIBRARIES.
|
||||
#Some systems are very picky about link order. They don't all agree
|
||||
#on the right order, either.
|
||||
|
||||
LIBS=-lm -lgd -lpng -lz
|
||||
LIBS=-lgd -lpng -lz -lm
|
||||
|
||||
#If you do have FreeType, JPEG and/or Xpm fully installed, uncomment a
|
||||
#variation of this and comment out the line above. Note that
|
||||
#Xpm requires X11. See also CFLAGS above.
|
||||
|
||||
#PLEASE NOTE: YOU MAY HAVE TO JUGGLE THE ORDER OF THE LIBRARIES.
|
||||
#Some systems are very picky about link order. They don't all agree
|
||||
#on the right order, either.
|
||||
#LIBS=-lgd -lpng -lz -ljpeg -lfreetype -lm -lttf
|
||||
|
||||
#LIBS=-lm -lgd -lpng -lz -ljpeg -lttf -lXpm -lX11
|
||||
#Note: for Freetype 1.x, use DHAVE_LIBTTF and -lttf instead.
|
||||
|
||||
#Typical install locations for freetype, zlib, xpm, libjpeg and libpng header files.
|
||||
#If yours are somewhere else, change this.
|
||||
#-I. is important to ensure that the version of gd you are installing
|
||||
#is used, and not an older release in your directory tree somewhere.
|
||||
#Typical install locations for freetype, zlib, xpm, libjpeg and libpng header
|
||||
#files. If yours are somewhere else, change this. -I. is important to
|
||||
#ensure that the version of gd you are installing is used, and not an
|
||||
#older release in your directory tree somewhere.
|
||||
|
||||
INCLUDEDIRS=-I. -I/usr/local/include -I/usr/include/X11 -I/usr/X11R6/include/X11
|
||||
INCLUDEDIRS=-I. -I/usr/include/freetype2 -I/usr/include/X11 -I/usr/X11R6/include/X11 -I/usr/local/include
|
||||
|
||||
#Typical install locations for freetype, zlib, xpm and libpng libraries.
|
||||
#If yours are somewhere else, other than a standard location
|
||||
|
@ -48,6 +53,8 @@ INCLUDEDIRS=-I. -I/usr/local/include -I/usr/include/X11 -I/usr/X11R6/include/X11
|
|||
#-L. as this allows the gd library itself to be found.
|
||||
#Put -L. first so that old versions of the gd library elsewhere
|
||||
#on your system can't cause conflicts while building a new one.
|
||||
#This line shouldn't hurt if you don't actually have some of the
|
||||
#optional libraries and directories.
|
||||
LIBDIRS=-L. -L/usr/local/lib -L/usr/lib/X11 -L/usr/X11R6/lib
|
||||
|
||||
#Location where libgd.a should be installed by "make install".
|
||||
|
@ -65,7 +72,7 @@ INSTALL_BIN=/usr/local/bin
|
|||
#
|
||||
#
|
||||
|
||||
VERSION=1.8.1
|
||||
VERSION=1.8.4
|
||||
|
||||
CC=$(COMPILER) $(INCLUDEDIRS)
|
||||
LINK=$(CC) $(LIBDIRS) $(LIBS)
|
||||
|
@ -73,7 +80,7 @@ LINK=$(CC) $(LIBDIRS) $(LIBS)
|
|||
PROGRAMS=$(BIN_PROGRAMS) $(TEST_PROGRAMS)
|
||||
|
||||
BIN_PROGRAMS=pngtogd pngtogd2 gdtopng gd2topng gd2copypal gdparttopng webpng
|
||||
TEST_PROGRAMS=gdtest gddemo gd2time gdtestttf
|
||||
TEST_PROGRAMS=gdtest gddemo gd2time gdtestft gdtestttf
|
||||
|
||||
all: libgd.a $(PROGRAMS)
|
||||
|
||||
|
@ -126,18 +133,22 @@ gdtest: gdtest.o libgd.a
|
|||
gd2time: gd2time.o libgd.a
|
||||
$(CC) gd2time.o -o gd2time $(LIBDIRS) $(LIBS)
|
||||
|
||||
gdtestft: gdtestft.o libgd.a
|
||||
$(CC) --verbose gdtestft.o -o gdtestft $(LIBDIRS) $(LIBS)
|
||||
gdtestttf: gdtestttf.o libgd.a
|
||||
$(CC) gdtestttf.o -o gdtestttf $(LIBDIRS) $(LIBS)
|
||||
$(CC) --verbose gdtestttf.o -o gdtestttf $(LIBDIRS) $(LIBS)
|
||||
|
||||
libgd.a: gd.o gd_gd.o gd_gd2.o gd_io.o gd_io_dp.o gd_io_file.o gd_ss.o \
|
||||
gd_io_ss.o gd_png.o gd_jpeg.o gdxpm.o gdfontt.o gdfonts.o gdfontmb.o gdfontl.o \
|
||||
gdfontg.o gdtables.o gdttf.o gdcache.o gdkanji.o wbmp.o gd_wbmp.o \
|
||||
gd.h gdfontt.h gdfonts.h gdfontmb.h gdfontl.h gdfontg.h
|
||||
gdfontg.o gdtables.o gdft.o gdttf.o gdcache.o gdkanji.o wbmp.o \
|
||||
gd_wbmp.o gdhelpers.o gd.h gdfontt.h gdfonts.h gdfontmb.h gdfontl.h \
|
||||
gdfontg.h gdhelpers.h
|
||||
rm -f libgd.a
|
||||
$(AR) rc libgd.a gd.o gd_gd.o gd_gd2.o gd_io.o gd_io_dp.o \
|
||||
gd_io_file.o gd_ss.o gd_io_ss.o gd_png.o gd_jpeg.o gdxpm.o \
|
||||
gdfontt.o gdfonts.o gdfontmb.o gdfontl.o gdfontg.o \
|
||||
gdtables.o gdttf.o gdcache.o gdkanji.o wbmp.o gd_wbmp.o
|
||||
gdtables.o gdft.o gdttf.o gdcache.o gdkanji.o wbmp.o \
|
||||
gd_wbmp.o gdhelpers.o
|
||||
-ranlib libgd.a
|
||||
|
||||
clean:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#NMAKE makefile for Windows 95/98/NT developers.
|
||||
#Produces a static library (libgd.lib). Thanks to Joe Gregorio.
|
||||
#This is out of date.
|
||||
|
||||
COMPILER=cl
|
||||
|
||||
|
@ -17,7 +18,10 @@ CFLAGS=-Ox -GX
|
|||
|
||||
#If you do have FreeType and/or Xpm fully installed, uncomment a
|
||||
#variation of this and comment out the line above. See also LIBS below.
|
||||
#CFLAGS=-O -DHAVE_XPM -DHAVE_LIBTTF
|
||||
#CFLAGS=-O -DHAVE_LIBXPM -DHAVE_LIBJPEG -DHAVE_LIBPNG -DHAVE_LIBTTF
|
||||
|
||||
# -DHAVE_LIBFREETYPE can be used instead of -DHAVE_TTF to use the
|
||||
# newer FreeType2 libraries
|
||||
|
||||
#Libraries required for applications
|
||||
LIBS=gd.lib libpng.lib zlib.lib
|
||||
|
@ -64,7 +68,7 @@ LINK=$(CC) $(LIBS)
|
|||
PROGRAMS=$(BIN_PROGRAMS) $(TEST_PROGRAMS)
|
||||
|
||||
BIN_PROGRAMS=pngtogd.exe pngtogd2.exe gdtopng.exe gd2topng.exe gd2copypal.exe gdparttopng.exe webpng.exe
|
||||
TEST_PROGRAMS=gdtest.exe gddemo.exe gd2time.exe gdtestttf.exe
|
||||
TEST_PROGRAMS=gdtest.exe gddemo.exe gd2time.exe gdtestttf.exe gdtestft.exe
|
||||
|
||||
all: gd.lib $(PROGRAMS)
|
||||
|
||||
|
@ -101,9 +105,12 @@ gd2time.exe: gd2time.c gd.lib
|
|||
gdtestttf.exe: gdtestttf.c gd.lib
|
||||
$(CC) gdtestttf.c $(LIBDIRS) $(LIBS)
|
||||
|
||||
gdtestft.exe: gdtestft.c gd.lib
|
||||
$(CC) gdtestft.c $(LIBDIRS) $(LIBS)
|
||||
|
||||
OBJS=gd.obj gd_gd.obj gd_gd2.obj gd_io.obj gd_io_dp.obj gd_io_file.obj gd_ss.obj \
|
||||
gd_io_ss.obj gd_png.obj gdxpm.obj gdfontt.obj gdfonts.obj gdfontmb.obj gdfontl.obj \
|
||||
gdfontg.obj gdtables.obj gdttf.obj gdcache.obj gdkanji.obj gd_jpeg.obj
|
||||
gdfontg.obj gdtables.obj gdttf.obj gdft.c gdcache.obj gdkanji.obj gd_jpeg.obj
|
||||
|
||||
gd.lib: $(OBJS) gd.h gdfontt.h gdfonts.h gdfontmb.h gdfontl.h gdfontg.h
|
||||
$(AR) $(OBJS) $(GDLIBS)
|
||||
|
|
70
src/gd.c
70
src/gd.c
|
@ -1,12 +1,10 @@
|
|||
#ifndef _OSD_POSIX /* _OSD_POSIX defines *alloc() in stdlib.h */
|
||||
#include <malloc.h>
|
||||
#endif /*_OSD_POSIX*/
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <zlib.h>
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
|
||||
#ifdef _OSD_POSIX /* BS2000 uses the EBCDIC char set instead of ASCII */
|
||||
#define CHARSET_EBCDIC
|
||||
|
@ -53,8 +51,8 @@ static const unsigned char gd_toascii[256] = {
|
|||
};
|
||||
#endif /*CHARSET_EBCDIC*/
|
||||
|
||||
extern int gdCosT[1024];
|
||||
extern int gdSinT[1024];
|
||||
extern int gdCosT[];
|
||||
extern int gdSinT[];
|
||||
|
||||
static void gdImageBrushApply(gdImagePtr im, int x, int y);
|
||||
static void gdImageTileApply(gdImagePtr im, int x, int y);
|
||||
|
@ -63,9 +61,9 @@ gdImagePtr gdImageCreate(int sx, int sy)
|
|||
{
|
||||
int i;
|
||||
gdImagePtr im;
|
||||
im = (gdImage *) malloc(sizeof(gdImage));
|
||||
im = (gdImage *) gdMalloc(sizeof(gdImage));
|
||||
/* NOW ROW-MAJOR IN GD 1.3 */
|
||||
im->pixels = (unsigned char **) malloc(sizeof(unsigned char *) * sy);
|
||||
im->pixels = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy);
|
||||
im->polyInts = 0;
|
||||
im->polyAllocated = 0;
|
||||
im->brush = 0;
|
||||
|
@ -73,7 +71,7 @@ gdImagePtr gdImageCreate(int sx, int sy)
|
|||
im->style = 0;
|
||||
for (i=0; (i<sy); i++) {
|
||||
/* NOW ROW-MAJOR IN GD 1.3 */
|
||||
im->pixels[i] = (unsigned char *) calloc(
|
||||
im->pixels[i] = (unsigned char *) gdCalloc(
|
||||
sx, sizeof(unsigned char));
|
||||
}
|
||||
im->sx = sx;
|
||||
|
@ -96,16 +94,16 @@ void gdImageDestroy(gdImagePtr im)
|
|||
{
|
||||
int i;
|
||||
for (i=0; (i<im->sy); i++) {
|
||||
free(im->pixels[i]);
|
||||
gdFree(im->pixels[i]);
|
||||
}
|
||||
free(im->pixels);
|
||||
gdFree(im->pixels);
|
||||
if (im->polyInts) {
|
||||
free(im->polyInts);
|
||||
gdFree(im->polyInts);
|
||||
}
|
||||
if (im->style) {
|
||||
free(im->style);
|
||||
gdFree(im->style);
|
||||
}
|
||||
free(im);
|
||||
gdFree(im);
|
||||
}
|
||||
|
||||
int gdImageColorClosest(gdImagePtr im, int r, int g, int b)
|
||||
|
@ -238,12 +236,14 @@ static RGBType* HWB_to_RGB( HWBType HWB, RGBType* RGB ) {
|
|||
case 5: RETURN_RGB(v, w, n);
|
||||
}
|
||||
|
||||
return RGB;
|
||||
|
||||
}
|
||||
|
||||
int gdImageColorClosestHWB(gdImagePtr im, int r, int g, int b)
|
||||
{
|
||||
int i;
|
||||
long rd, gd, bd;
|
||||
/* long rd, gd, bd; */
|
||||
int ct = (-1);
|
||||
int first = 1;
|
||||
float mindist = 0;
|
||||
|
@ -1111,12 +1111,14 @@ void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int sr
|
|||
int c, dc;
|
||||
int x, y;
|
||||
int tox, toy;
|
||||
int i;
|
||||
int ncR, ncG, ncB;
|
||||
#if 0
|
||||
int i;
|
||||
int colorMap[gdMaxColors];
|
||||
for (i=0; (i<gdMaxColors); i++) {
|
||||
colorMap[i] = (-1);
|
||||
}
|
||||
#endif
|
||||
toy = dstY;
|
||||
for (y=srcY; (y < (srcY + h)); y++) {
|
||||
tox = dstX;
|
||||
|
@ -1170,14 +1172,16 @@ void gdImageCopyMergeGray(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, in
|
|||
int c, dc;
|
||||
int x, y;
|
||||
int tox, toy;
|
||||
int i;
|
||||
int ncR, ncG, ncB;
|
||||
int colorMap[gdMaxColors];
|
||||
float g;
|
||||
#if 0
|
||||
int i;
|
||||
int colorMap[gdMaxColors];
|
||||
|
||||
for (i=0; (i<gdMaxColors); i++) {
|
||||
colorMap[i] = (-1);
|
||||
}
|
||||
#endif
|
||||
toy = dstY;
|
||||
for (y=srcY; (y < (srcY + h)); y++) {
|
||||
tox = dstX;
|
||||
|
@ -1236,8 +1240,8 @@ void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int
|
|||
/* We only need to use floating point to determine the correct
|
||||
stretch vector for one line's worth. */
|
||||
double accum;
|
||||
stx = (int *) malloc(sizeof(int) * srcW);
|
||||
sty = (int *) malloc(sizeof(int) * srcH);
|
||||
stx = (int *) gdMalloc(sizeof(int) * srcW);
|
||||
sty = (int *) gdMalloc(sizeof(int) * srcH);
|
||||
accum = 0;
|
||||
for (i=0; (i < srcW); i++) {
|
||||
int got;
|
||||
|
@ -1306,8 +1310,8 @@ void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int
|
|||
toy++;
|
||||
}
|
||||
}
|
||||
free(stx);
|
||||
free(sty);
|
||||
gdFree(stx);
|
||||
gdFree(sty);
|
||||
}
|
||||
|
||||
gdImagePtr
|
||||
|
@ -1458,14 +1462,14 @@ void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c)
|
|||
return;
|
||||
}
|
||||
if (!im->polyAllocated) {
|
||||
im->polyInts = (int *) malloc(sizeof(int) * n);
|
||||
im->polyInts = (int *) gdMalloc(sizeof(int) * n);
|
||||
im->polyAllocated = n;
|
||||
}
|
||||
if (im->polyAllocated < n) {
|
||||
while (im->polyAllocated < n) {
|
||||
im->polyAllocated *= 2;
|
||||
}
|
||||
im->polyInts = (int *) realloc(im->polyInts,
|
||||
im->polyInts = (int *) gdRealloc(im->polyInts,
|
||||
sizeof(int) * im->polyAllocated);
|
||||
}
|
||||
miny = p[0].y;
|
||||
|
@ -1528,10 +1532,10 @@ int gdCompareInt(const void *a, const void *b)
|
|||
void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels)
|
||||
{
|
||||
if (im->style) {
|
||||
free(im->style);
|
||||
gdFree(im->style);
|
||||
}
|
||||
im->style = (int *)
|
||||
malloc(sizeof(int) * noOfPixels);
|
||||
gdMalloc(sizeof(int) * noOfPixels);
|
||||
memcpy(im->style, style, sizeof(int) * noOfPixels);
|
||||
im->styleLength = noOfPixels;
|
||||
im->stylePos = 0;
|
||||
|
@ -1609,22 +1613,18 @@ int gdImageCompare(gdImagePtr im1, gdImagePtr im2)
|
|||
cmpStatus |= GD_CMP_TRANSPARENT;
|
||||
}
|
||||
|
||||
sx = im1->sx;
|
||||
if (im1->sx != im2->sx) {
|
||||
cmpStatus |= GD_CMP_SIZE_X + GD_CMP_IMAGE;
|
||||
if (im1->sx < im2->sx) {
|
||||
sx = im1->sx;
|
||||
} else {
|
||||
if (im2->sx < im1->sx) {
|
||||
sx = im2->sx;
|
||||
}
|
||||
} else {
|
||||
sx = im1->sx;
|
||||
}
|
||||
|
||||
sy = im1->sy;
|
||||
if (im1->sy != im2->sy) {
|
||||
cmpStatus |= GD_CMP_SIZE_Y + GD_CMP_IMAGE;
|
||||
if (im1->sy < im2->sy) {
|
||||
sy = im1->sy;
|
||||
} else {
|
||||
if (im2->sy < im1->sy) {
|
||||
sy = im2->sy;
|
||||
}
|
||||
}
|
||||
|
@ -1633,8 +1633,8 @@ int gdImageCompare(gdImagePtr im1, gdImagePtr im2)
|
|||
cmpStatus |= GD_CMP_NUM_COLORS;
|
||||
}
|
||||
|
||||
for ( y = 0 ; (y<im1->sy) ; y++ ) {
|
||||
for ( x = 0 ; (x < im1->sx) ; x++ ) {
|
||||
for ( y = 0 ; (y < sy) ; y++ ) {
|
||||
for ( x = 0 ; (x < sx) ; x++ ) {
|
||||
p1 = im1->pixels[y][x];
|
||||
p2 = im2->pixels[y][x];
|
||||
|
||||
|
|
40
src/gd.h
40
src/gd.h
|
@ -5,6 +5,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* default fontpath for unix systems */
|
||||
#define DEFAULT_FONTPATH "/usr/share/fonts/truetype"
|
||||
#define PATHSEPARATOR ":"
|
||||
|
||||
/* gd.h: declarations file for the graphic-draw module.
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
|
@ -91,6 +95,10 @@ typedef gdFont *gdFontPtr;
|
|||
gdImagePtr gdImageCreate(int sx, int sy);
|
||||
gdImagePtr gdImageCreateFromPng(FILE *fd);
|
||||
gdImagePtr gdImageCreateFromPngCtx(gdIOCtxPtr in);
|
||||
gdImagePtr gdImageCreateFromWBMP(FILE *inFile);
|
||||
gdImagePtr gdImageCreateFromWBMPCtx(gdIOCtx *infile);
|
||||
gdImagePtr gdImageCreateFromJpeg(FILE *infile);
|
||||
gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile);
|
||||
|
||||
/* A custom data source. */
|
||||
/* The source function must return -1 on error, otherwise the number
|
||||
|
@ -135,11 +143,15 @@ void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s,
|
|||
void gdImageString16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
|
||||
void gdImageStringUp16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
|
||||
|
||||
char *gdImageStringTTF(gdImage *im, int *brect, int fg, char *fontname,
|
||||
/* FreeType 1.x text output (DEPRECATED) */
|
||||
char *gdImageStringTTF(gdImage *im, int *brect, int fg, char *fontlist,
|
||||
double ptsize, double angle, int x, int y, char *string);
|
||||
|
||||
/* FreeType 2 text output (NIFTY) */
|
||||
char *gdImageStringFT(gdImage *im, int *brect, int fg, char *fontlist,
|
||||
double ptsize, double angle, int x, int y, char *string);
|
||||
|
||||
/* Point type for use in polygon drawing. */
|
||||
|
||||
typedef struct {
|
||||
int x, y;
|
||||
} gdPoint, *gdPointPtr;
|
||||
|
@ -159,16 +171,19 @@ void gdImagePngCtx(gdImagePtr im, gdIOCtx *out);
|
|||
|
||||
void gdImageWBMP(gdImagePtr image, int fg, FILE *out);
|
||||
void gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out);
|
||||
void *gdImageWBMPPtr(gdImagePtr im, int *size, int fg);
|
||||
gdImagePtr gdImageCreateFromWBMP(FILE *inFile);
|
||||
gdImagePtr gdImageCreateFromWBMPCtx(gdIOCtx *infile);
|
||||
|
||||
/* Guaranteed to correctly free memory returned
|
||||
by the gdImage*Ptr functions */
|
||||
void gdFree(void *m);
|
||||
|
||||
/* Best to free this memory with gdFree(), not free() */
|
||||
void *gdImageWBMPPtr(gdImagePtr im, int *size, int fg);
|
||||
|
||||
void gdImageJpeg(gdImagePtr im, FILE *out, int quality);
|
||||
void gdImageJpegCtx(gdImagePtr im, gdIOCtx *out, int quality);
|
||||
|
||||
/* Best to free this memory with gdFree(), not free() */
|
||||
void *gdImageJpegPtr(gdImagePtr im, int *size, int quality);
|
||||
gdImagePtr gdImageCreateFromJpeg(FILE *infile);
|
||||
gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile);
|
||||
|
||||
/* A custom data sink. For backwards compatibility. Use
|
||||
gdIOCtx instead. */
|
||||
|
@ -184,9 +199,16 @@ void gdImagePngToSink(gdImagePtr im, gdSinkPtr out);
|
|||
|
||||
void gdImageGd(gdImagePtr im, FILE *out);
|
||||
void gdImageGd2(gdImagePtr im, FILE *out, int cs, int fmt);
|
||||
|
||||
/* Best to free this memory with gdFree(), not free() */
|
||||
void* gdImagePngPtr(gdImagePtr im, int *size);
|
||||
|
||||
/* Best to free this memory with gdFree(), not free() */
|
||||
void* gdImageGdPtr(gdImagePtr im, int *size);
|
||||
|
||||
/* Best to free this memory with gdFree(), not free() */
|
||||
void* gdImageGd2Ptr(gdImagePtr im, int cs, int fmt, int *size);
|
||||
|
||||
void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color);
|
||||
void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color);
|
||||
void gdImageFill(gdImagePtr im, int x, int y, int color);
|
||||
|
@ -222,7 +244,6 @@ gdIOCtx* gdNewDynamicCtx(int, void*);
|
|||
gdIOCtx* gdNewSSCtx(gdSourcePtr in, gdSinkPtr out);
|
||||
void* gdDPExtractData(struct gdIOCtx* ctx, int *size);
|
||||
|
||||
|
||||
#define GD2_CHUNKSIZE 128
|
||||
#define GD2_CHUNKSIZE_MIN 64
|
||||
#define GD2_CHUNKSIZE_MAX 4096
|
||||
|
@ -244,6 +265,9 @@ int gdImageCompare(gdImagePtr im1, gdImagePtr im2);
|
|||
#define GD_CMP_BACKGROUND 64 /* Background colour */
|
||||
#define GD_CMP_INTERLACE 128 /* Interlaced setting */
|
||||
|
||||
/* resolution affects ttf font rendering, particularly hinting */
|
||||
#define GD_RESOLUTION 96 /* pixels per inch */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
57
src/gd_gd2.c
57
src/gd_gd2.c
|
@ -17,6 +17,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <zlib.h>
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
@ -128,7 +129,7 @@ int _gd2GetHeader(gdIOCtxPtr in, int *sx, int *sy,
|
|||
nc = (*ncx) * (*ncy);
|
||||
GD2_DBG(printf("Reading %d chunk index entries\n", nc));
|
||||
sidx = sizeof(t_chunk_info) * nc;
|
||||
cidx = calloc(sidx,1);
|
||||
cidx = gdCalloc(sidx,1);
|
||||
for (i = 0; i < nc; i++) {
|
||||
if (gdGetInt(&cidx[i].offset, in) != 1) {
|
||||
goto fail1;
|
||||
|
@ -230,14 +231,14 @@ gdImagePtr gdImageCreateFromGd2Ctx(gdIOCtxPtr in)
|
|||
int ncx, ncy, nc, cs, cx, cy;
|
||||
int x, y, ylo, yhi, xlo, xhi;
|
||||
int ch, vers, fmt;
|
||||
t_chunk_info *chunkIdx = NULL; /* So we can free it with impunity. */
|
||||
char *chunkBuf = NULL; /* So we can free it with impunity. */
|
||||
t_chunk_info *chunkIdx = NULL; /* So we can gdFree it with impunity. */
|
||||
char *chunkBuf = NULL; /* So we can gdFree it with impunity. */
|
||||
int chunkNum = 0;
|
||||
int chunkMax;
|
||||
uLongf chunkLen;
|
||||
int chunkPos;
|
||||
int compMax;
|
||||
char *compBuf = NULL; /* So we can free it with impunity. */
|
||||
char *compBuf = NULL; /* So we can gdFree it with impunity. */
|
||||
|
||||
gdImagePtr im;
|
||||
|
||||
|
@ -262,8 +263,8 @@ gdImagePtr gdImageCreateFromGd2Ctx(gdIOCtxPtr in)
|
|||
|
||||
/* Allocate buffers */
|
||||
chunkMax = cs * cs;
|
||||
chunkBuf = calloc(chunkMax,1);
|
||||
compBuf = calloc(compMax,1);
|
||||
chunkBuf = gdCalloc(chunkMax,1);
|
||||
compBuf = gdCalloc(compMax,1);
|
||||
GD2_DBG(printf("Largest compressed chunk is %d bytes\n",compMax));
|
||||
};
|
||||
|
||||
|
@ -333,9 +334,9 @@ gdImagePtr gdImageCreateFromGd2Ctx(gdIOCtxPtr in)
|
|||
|
||||
GD2_DBG(printf("Freeing memory\n"));
|
||||
|
||||
free(chunkBuf);
|
||||
free(compBuf);
|
||||
free(chunkIdx);
|
||||
gdFree(chunkBuf);
|
||||
gdFree(compBuf);
|
||||
gdFree(chunkIdx);
|
||||
|
||||
GD2_DBG(printf("Done\n"));
|
||||
|
||||
|
@ -343,9 +344,9 @@ gdImagePtr gdImageCreateFromGd2Ctx(gdIOCtxPtr in)
|
|||
|
||||
fail2:
|
||||
gdImageDestroy(im);
|
||||
free(chunkBuf);
|
||||
free(compBuf);
|
||||
free(chunkIdx);
|
||||
gdFree(chunkBuf);
|
||||
gdFree(compBuf);
|
||||
gdFree(chunkIdx);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
@ -417,8 +418,8 @@ gdImagePtr gdImageCreateFromGd2PartCtx(gdIOCtx *in, int srcx, int srcy, int w, i
|
|||
compMax++;
|
||||
|
||||
chunkMax = cs * cs;
|
||||
chunkBuf = calloc(chunkMax,1);
|
||||
compBuf = calloc(compMax,1);
|
||||
chunkBuf = gdCalloc(chunkMax,1);
|
||||
compBuf = gdCalloc(compMax,1);
|
||||
};
|
||||
|
||||
/* Don't bother with this... */
|
||||
|
@ -515,18 +516,18 @@ gdImagePtr gdImageCreateFromGd2PartCtx(gdIOCtx *in, int srcx, int srcy, int w, i
|
|||
};
|
||||
};
|
||||
|
||||
free(chunkBuf);
|
||||
free(compBuf);
|
||||
free(chunkIdx);
|
||||
gdFree(chunkBuf);
|
||||
gdFree(compBuf);
|
||||
gdFree(chunkIdx);
|
||||
|
||||
return im;
|
||||
|
||||
fail2:
|
||||
gdImageDestroy(im);
|
||||
fail1:
|
||||
free(chunkBuf);
|
||||
free(compBuf);
|
||||
free(chunkIdx);
|
||||
gdFree(chunkBuf);
|
||||
gdFree(compBuf);
|
||||
gdFree(chunkIdx);
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -561,8 +562,8 @@ static void _gdImageGd2(gdImagePtr im, gdIOCtx *out, int cs, int fmt)
|
|||
int x, y, ylo, yhi, xlo, xhi;
|
||||
int chunkLen;
|
||||
int chunkNum = 0;
|
||||
char *chunkData = NULL; /* So we can free it with impunity. */
|
||||
char *compData = NULL; /* So we can free it with impunity. */
|
||||
char *chunkData = NULL; /* So we can gdFree it with impunity. */
|
||||
char *compData = NULL; /* So we can gdFree it with impunity. */
|
||||
uLongf compLen;
|
||||
int idxPos;
|
||||
int idxSize;
|
||||
|
@ -613,8 +614,8 @@ static void _gdImageGd2(gdImagePtr im, gdIOCtx *out, int cs, int fmt)
|
|||
/* */
|
||||
/* Allocate the buffers. */
|
||||
/* */
|
||||
chunkData = calloc(cs*cs,1);
|
||||
compData = calloc(compMax,1);
|
||||
chunkData = gdCalloc(cs*cs,1);
|
||||
compData = gdCalloc(compMax,1);
|
||||
|
||||
/* */
|
||||
/* Save the file position of chunk index, and allocate enough space for */
|
||||
|
@ -625,7 +626,7 @@ static void _gdImageGd2(gdImagePtr im, gdIOCtx *out, int cs, int fmt)
|
|||
GD2_DBG(printf("Index size is %d\n", idxSize));
|
||||
gdSeek(out,idxPos+idxSize);
|
||||
|
||||
chunkIdx = calloc(idxSize * sizeof(t_chunk_info),1);
|
||||
chunkIdx = gdCalloc(idxSize * sizeof(t_chunk_info),1);
|
||||
};
|
||||
|
||||
_gdPutColors(im, out);
|
||||
|
@ -704,9 +705,9 @@ static void _gdImageGd2(gdImagePtr im, gdIOCtx *out, int cs, int fmt)
|
|||
};
|
||||
|
||||
GD2_DBG(printf("Freeing memory\n"));
|
||||
free(chunkData);
|
||||
free(compData);
|
||||
free(chunkIdx);
|
||||
gdFree(chunkData);
|
||||
gdFree(compData);
|
||||
gdFree(chunkIdx);
|
||||
GD2_DBG(printf("Done\n"));
|
||||
|
||||
/*printf("Memory block size is %d\n",gdTell(out)); */
|
||||
|
|
|
@ -141,7 +141,7 @@ int gdGetBuf(void *buf, int size, gdIOCtx* ctx)
|
|||
}
|
||||
|
||||
|
||||
int gdSeek(gdIOCtx *ctx, int pos)
|
||||
int gdSeek(gdIOCtx *ctx, const int pos)
|
||||
{
|
||||
IO_DBG(printf("Seeking...\n"));
|
||||
return ((ctx->seek)(ctx, pos));
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
@ -44,9 +45,9 @@ typedef struct dpIOCtx *dpIOCtxPtr;
|
|||
/* these functions operate on in-memory dynamic pointers */
|
||||
static int allocDynamic (dynamicPtr* dp,int initialSize, void *data);
|
||||
static int appendDynamic (dynamicPtr* dp, const void* src, int size);
|
||||
static int reallocDynamic (dynamicPtr* dp, int required);
|
||||
static int gdReallocDynamic (dynamicPtr* dp, int required);
|
||||
static int trimDynamic (dynamicPtr* dp);
|
||||
static void freeDynamicCtx(struct gdIOCtx* ctx);
|
||||
static void gdFreeDynamicCtx(struct gdIOCtx* ctx);
|
||||
static dynamicPtr* newDynamic(int initialSize, void *data);
|
||||
|
||||
static int dynamicPutbuf( struct gdIOCtx*, const void *, int );
|
||||
|
@ -63,14 +64,14 @@ gdIOCtx* gdNewDynamicCtx (int initialSize, void *data) {
|
|||
dpIOCtx *ctx;
|
||||
dynamicPtr* dp;
|
||||
|
||||
ctx = (dpIOCtx*) malloc(sizeof(dpIOCtx));
|
||||
ctx = (dpIOCtx*) gdMalloc(sizeof(dpIOCtx));
|
||||
if (ctx == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dp = newDynamic(initialSize, data);
|
||||
if (!dp) {
|
||||
free(ctx);
|
||||
gdFree(ctx);
|
||||
return NULL;
|
||||
};
|
||||
|
||||
|
@ -85,7 +86,7 @@ gdIOCtx* gdNewDynamicCtx (int initialSize, void *data) {
|
|||
ctx->ctx.seek = dynamicSeek;
|
||||
ctx->ctx.tell = dynamicTell;
|
||||
|
||||
ctx->ctx.free = freeDynamicCtx;
|
||||
ctx->ctx.free = gdFreeDynamicCtx;
|
||||
|
||||
return (gdIOCtx*)ctx;
|
||||
}
|
||||
|
@ -108,7 +109,7 @@ void* gdDPExtractData(struct gdIOCtx* ctx, int *size)
|
|||
*size = 0;
|
||||
data = NULL;
|
||||
if (dp->data != NULL) {
|
||||
free(dp->data);
|
||||
gdFree(dp->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +121,7 @@ void* gdDPExtractData(struct gdIOCtx* ctx, int *size)
|
|||
}
|
||||
|
||||
static
|
||||
void freeDynamicCtx(struct gdIOCtx* ctx)
|
||||
void gdFreeDynamicCtx(struct gdIOCtx* ctx)
|
||||
{
|
||||
dynamicPtr *dp;
|
||||
dpIOCtx *dctx;
|
||||
|
@ -128,18 +129,18 @@ void freeDynamicCtx(struct gdIOCtx* ctx)
|
|||
dctx = (dpIOCtx*) ctx;
|
||||
dp = dctx->dp;
|
||||
|
||||
free(ctx);
|
||||
gdFree(ctx);
|
||||
|
||||
/* clean up the data block and return it */
|
||||
if (dp->data != NULL) {
|
||||
free(dp->data);
|
||||
gdFree(dp->data);
|
||||
dp->data = NULL;
|
||||
}
|
||||
|
||||
dp->realSize=0;
|
||||
dp->logicalSize=0;
|
||||
|
||||
free(dp);
|
||||
gdFree(dp);
|
||||
|
||||
}
|
||||
|
||||
|
@ -164,7 +165,7 @@ static int dynamicSeek(struct gdIOCtx* ctx, const int pos)
|
|||
|
||||
bytesNeeded = pos;
|
||||
if (bytesNeeded > dp->realSize) {
|
||||
if (!reallocDynamic(dp,dp->realSize*2)) {
|
||||
if (!gdReallocDynamic(dp,dp->realSize*2)) {
|
||||
dp->dataGood = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -186,7 +187,7 @@ static int dynamicSeek(struct gdIOCtx* ctx, const int pos)
|
|||
/* return data as a dynamic pointer */
|
||||
static dynamicPtr* newDynamic (int initialSize, void *data) {
|
||||
dynamicPtr* dp;
|
||||
dp = (dynamicPtr*) malloc(sizeof(dynamicPtr));
|
||||
dp = (dynamicPtr*) gdMalloc(sizeof(dynamicPtr));
|
||||
if (dp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -280,7 +281,7 @@ allocDynamic (dynamicPtr* dp,int initialSize, void *data) {
|
|||
if (data == NULL) {
|
||||
dp->logicalSize = 0;
|
||||
dp->dataGood = FALSE;
|
||||
dp->data = malloc(initialSize);
|
||||
dp->data = gdMalloc(initialSize);
|
||||
} else {
|
||||
dp->logicalSize = initialSize;
|
||||
dp->dataGood = TRUE;
|
||||
|
@ -310,7 +311,7 @@ appendDynamic (dynamicPtr* dp, const void* src, int size) {
|
|||
bytesNeeded = dp->pos + size;
|
||||
|
||||
if (bytesNeeded > dp->realSize) {
|
||||
if (!reallocDynamic(dp,bytesNeeded*2)) {
|
||||
if (!gdReallocDynamic(dp,bytesNeeded*2)) {
|
||||
dp->dataGood = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -333,19 +334,19 @@ appendDynamic (dynamicPtr* dp, const void* src, int size) {
|
|||
|
||||
/* grow (or shrink) dynamic pointer */
|
||||
static int
|
||||
reallocDynamic (dynamicPtr* dp, int required) {
|
||||
gdReallocDynamic (dynamicPtr* dp, int required) {
|
||||
void* newPtr;
|
||||
|
||||
/* First try realloc(). If that doesn't work, make a new
|
||||
/* First try gdRealloc(). If that doesn't work, make a new
|
||||
memory block and copy. */
|
||||
if ( (newPtr = realloc(dp->data,required)) ) {
|
||||
if ( (newPtr = gdRealloc(dp->data,required)) ) {
|
||||
dp->realSize = required;
|
||||
dp->data = newPtr;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* create a new pointer */
|
||||
newPtr = malloc(required);
|
||||
newPtr = gdMalloc(required);
|
||||
if (!newPtr) {
|
||||
dp->dataGood = FALSE;
|
||||
return FALSE;
|
||||
|
@ -353,7 +354,7 @@ reallocDynamic (dynamicPtr* dp, int required) {
|
|||
|
||||
/* copy the old data into it */
|
||||
memcpy(newPtr,dp->data,dp->logicalSize);
|
||||
free(dp->data);
|
||||
gdFree(dp->data);
|
||||
dp->data = newPtr;
|
||||
|
||||
dp->realSize = required;
|
||||
|
@ -363,6 +364,6 @@ reallocDynamic (dynamicPtr* dp, int required) {
|
|||
/* trim pointer so that its real and logical sizes match */
|
||||
static int
|
||||
trimDynamic (dynamicPtr* dp) {
|
||||
return reallocDynamic(dp,dp->logicalSize);
|
||||
return gdReallocDynamic(dp,dp->logicalSize);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
|
||||
/* this is used for creating images in main memory*/
|
||||
|
||||
|
@ -42,13 +43,13 @@ static int fileGetchar( gdIOCtx* ctx);
|
|||
|
||||
static int fileSeek(struct gdIOCtx*, const int);
|
||||
static long fileTell(struct gdIOCtx*);
|
||||
static void freeFileCtx(gdIOCtx *ctx);
|
||||
static void gdFreeFileCtx(gdIOCtx *ctx);
|
||||
|
||||
/* return data as a dynamic pointer */
|
||||
gdIOCtx* gdNewFileCtx (FILE *f) {
|
||||
fileIOCtx *ctx;
|
||||
|
||||
ctx = (fileIOCtx*) malloc(sizeof(fileIOCtx));
|
||||
ctx = (fileIOCtx*) gdMalloc(sizeof(fileIOCtx));
|
||||
if (ctx == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -64,15 +65,15 @@ gdIOCtx* gdNewFileCtx (FILE *f) {
|
|||
ctx->ctx.tell = fileTell;
|
||||
ctx->ctx.seek = fileSeek;
|
||||
|
||||
ctx->ctx.free = freeFileCtx;
|
||||
ctx->ctx.free = gdFreeFileCtx;
|
||||
|
||||
return (gdIOCtx*)ctx;
|
||||
}
|
||||
|
||||
static
|
||||
void freeFileCtx(gdIOCtx *ctx)
|
||||
void gdFreeFileCtx(gdIOCtx *ctx)
|
||||
{
|
||||
free(ctx);
|
||||
gdFree(ctx);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
|
||||
/* this is used for creating images in main memory*/
|
||||
|
||||
|
@ -41,13 +42,13 @@ static int sourceGetbuf( gdIOCtx*, void *, int );
|
|||
static int sourceGetchar( gdIOCtx* ctx);
|
||||
static int sinkPutbuf( gdIOCtx* ctx, const void *buf, int size );
|
||||
static void sinkPutchar( gdIOCtx* ctx, int a );
|
||||
static void freeSsCtx(gdIOCtx *ctx);
|
||||
static void gdFreeSsCtx(gdIOCtx *ctx);
|
||||
|
||||
/* return data as a dynamic pointer */
|
||||
gdIOCtx* gdNewSSCtx (gdSourcePtr src, gdSinkPtr snk) {
|
||||
ssIOCtxPtr ctx;
|
||||
|
||||
ctx = (ssIOCtxPtr) malloc(sizeof(ssIOCtx));
|
||||
ctx = (ssIOCtxPtr) gdMalloc(sizeof(ssIOCtx));
|
||||
if (ctx == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -64,15 +65,15 @@ gdIOCtx* gdNewSSCtx (gdSourcePtr src, gdSinkPtr snk) {
|
|||
ctx->ctx.tell = NULL;
|
||||
ctx->ctx.seek = NULL;
|
||||
|
||||
ctx->ctx.free = freeSsCtx;
|
||||
ctx->ctx.free = gdFreeSsCtx;
|
||||
|
||||
return (gdIOCtx*)ctx;
|
||||
}
|
||||
|
||||
static
|
||||
void freeSsCtx(gdIOCtx *ctx)
|
||||
void gdFreeSsCtx(gdIOCtx *ctx)
|
||||
{
|
||||
free(ctx);
|
||||
gdFree(ctx);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
* major CGI brain damage
|
||||
*/
|
||||
|
||||
#ifdef HAVE_JPEG
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
|
@ -28,8 +26,11 @@
|
|||
#include "jpeglib.h"
|
||||
#include "jerror.h"
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
|
||||
static const char * const GD_JPEG_VERSION = "1.0";
|
||||
#ifdef HAVE_LIBJPEG
|
||||
|
||||
static const char * const GD_JPEG_VERSION = "2.0";
|
||||
|
||||
typedef struct _jmpbuf_wrapper {
|
||||
jmp_buf jmpbuf;
|
||||
|
@ -94,7 +95,7 @@ gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
|
|||
struct jpeg_compress_struct cinfo;
|
||||
struct jpeg_error_mgr jerr;
|
||||
int i, j, jidx;
|
||||
/* volatile so we can free it on return from longjmp */
|
||||
/* volatile so we can gdFree it on return from longjmp */
|
||||
volatile JSAMPROW row = 0;
|
||||
JSAMPROW rowptr[1];
|
||||
jmpbuf_wrapper jmpbufw;
|
||||
|
@ -121,7 +122,7 @@ gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
|
|||
if (setjmp(jmpbufw.jmpbuf) != 0) {
|
||||
/* we're here courtesy of longjmp */
|
||||
if (row)
|
||||
free(row);
|
||||
gdFree(row);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -148,11 +149,11 @@ gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
|
|||
|
||||
jpeg_gdIOCtx_dest(&cinfo, outfile);
|
||||
|
||||
row = (JSAMPROW)calloc(1, cinfo.image_width * cinfo.input_components
|
||||
row = (JSAMPROW)gdCalloc(1, cinfo.image_width * cinfo.input_components
|
||||
* sizeof(JSAMPLE));
|
||||
if (row == 0) {
|
||||
fprintf(stderr, "gd-jpeg: error: unable to allocate JPEG row "
|
||||
"structure: calloc returns NULL\n");
|
||||
"structure: gdCalloc returns NULL\n");
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
return;
|
||||
}
|
||||
|
@ -201,7 +202,7 @@ gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
|
|||
|
||||
jpeg_finish_compress(&cinfo);
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
free(row);
|
||||
gdFree(row);
|
||||
}
|
||||
|
||||
gdImagePtr gdImageCreateFromJpeg(FILE *inFile)
|
||||
|
@ -227,7 +228,7 @@ gdImageCreateFromJpegCtx(gdIOCtx *infile)
|
|||
struct jpeg_decompress_struct cinfo;
|
||||
struct jpeg_error_mgr jerr;
|
||||
jmpbuf_wrapper jmpbufw;
|
||||
/* volatile so we can free them after longjmp */
|
||||
/* volatile so we can gdFree them after longjmp */
|
||||
volatile JSAMPROW row = 0;
|
||||
volatile gdImagePtr im = 0;
|
||||
JSAMPROW rowptr[1];
|
||||
|
@ -248,7 +249,7 @@ gdImageCreateFromJpegCtx(gdIOCtx *infile)
|
|||
if (setjmp(jmpbufw.jmpbuf) != 0) {
|
||||
/* we're here courtesy of longjmp */
|
||||
if (row)
|
||||
free(row);
|
||||
gdFree(row);
|
||||
if (im)
|
||||
gdImageDestroy(im);
|
||||
return 0;
|
||||
|
@ -373,10 +374,10 @@ gdImageCreateFromJpegCtx(gdIOCtx *infile)
|
|||
#endif
|
||||
}
|
||||
|
||||
row = calloc(cinfo.output_width, sizeof(JSAMPLE));
|
||||
row = gdCalloc(cinfo.output_width, sizeof(JSAMPLE));
|
||||
if (row == 0) {
|
||||
fprintf(stderr, "gd-jpeg: error: unable to allocate row for"
|
||||
" JPEG scanline: calloc returns NULL\n");
|
||||
" JPEG scanline: gdCalloc returns NULL\n");
|
||||
goto error;
|
||||
}
|
||||
rowptr[0] = row;
|
||||
|
@ -399,13 +400,13 @@ gdImageCreateFromJpegCtx(gdIOCtx *infile)
|
|||
|
||||
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
free(row);
|
||||
gdFree(row);
|
||||
return im;
|
||||
|
||||
error:
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
if (row)
|
||||
free(row);
|
||||
gdFree(row);
|
||||
if (im)
|
||||
gdImageDestroy(im);
|
||||
return 0;
|
||||
|
@ -503,8 +504,8 @@ fill_input_buffer (j_decompress_ptr cinfo)
|
|||
{
|
||||
my_src_ptr src = (my_src_ptr) cinfo->src;
|
||||
size_t nbytes = 0;
|
||||
size_t got;
|
||||
char *s;
|
||||
/* size_t got; */
|
||||
/* char *s; */
|
||||
memset(src->buffer, 0, INPUT_BUF_SIZE);
|
||||
while (nbytes < INPUT_BUF_SIZE) {
|
||||
int got = gdGetBuf(src->buffer + nbytes,
|
||||
|
@ -593,7 +594,10 @@ skip_input_data (j_decompress_ptr cinfo, long num_bytes)
|
|||
void
|
||||
term_source (j_decompress_ptr cinfo)
|
||||
{
|
||||
#if 0
|
||||
/* never used */
|
||||
my_src_ptr src = (my_src_ptr) cinfo->src;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
51
src/gd_png.c
51
src/gd_png.c
|
@ -3,11 +3,14 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
#include "png.h" /* includes zlib.h and setjmp.h */
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#ifdef HAVE_LIBPNG
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
gd_png.c Copyright 1999 Greg Roelofs and Thomas Boutell
|
||||
|
@ -28,6 +31,7 @@
|
|||
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PNG_SETJMP_NOT_SUPPORTED
|
||||
typedef struct _jmpbuf_wrapper {
|
||||
jmp_buf jmpbuf;
|
||||
} jmpbuf_wrapper;
|
||||
|
@ -60,7 +64,7 @@ static void gdPngErrorHandler(png_structp png_ptr, png_const_charp msg)
|
|||
|
||||
longjmp(jmpbuf_ptr->jmpbuf, 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void gdPngReadData(png_structp png_ptr,
|
||||
png_bytep data, png_size_t length)
|
||||
|
@ -121,8 +125,12 @@ gdImagePtr gdImageCreateFromPngCtx(gdIOCtx *infile)
|
|||
if (!png_check_sig(sig, 8))
|
||||
return NULL; /* bad signature */
|
||||
|
||||
#ifndef PNG_SETJMP_NOT_SUPPORTED
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, &gdPngJmpbufStruct,
|
||||
gdPngErrorHandler, NULL);
|
||||
#else
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
#endif
|
||||
if (png_ptr == NULL) {
|
||||
fprintf(stderr, "gd-png error: cannot allocate libpng main struct\n");
|
||||
return NULL;
|
||||
|
@ -141,11 +149,13 @@ gdImagePtr gdImageCreateFromPngCtx(gdIOCtx *infile)
|
|||
|
||||
/* setjmp() must be called in every non-callback function that calls a
|
||||
* PNG-reading libpng function */
|
||||
#ifndef PNG_SETJMP_NOT_SUPPORTED
|
||||
if (setjmp(gdPngJmpbufStruct.jmpbuf)) {
|
||||
fprintf(stderr, "gd-png error: setjmp returns error condition\n");
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
png_set_sig_bytes(png_ptr, 8); /* we already read the 8 signature bytes */
|
||||
|
||||
|
@ -203,7 +213,7 @@ gdImagePtr gdImageCreateFromPngCtx(gdIOCtx *infile)
|
|||
case PNG_COLOR_TYPE_GRAY:
|
||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||
/* create a fake palette and check for single-shade transparency */
|
||||
if ((palette = (png_colorp)malloc(256*sizeof(png_color))) == NULL) {
|
||||
if ((palette = (png_colorp)gdMalloc(256*sizeof(png_color))) == NULL) {
|
||||
fprintf(stderr, "gd-png error: cannot allocate gray palette\n");
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return NULL;
|
||||
|
@ -238,7 +248,7 @@ gdImagePtr gdImageCreateFromPngCtx(gdIOCtx *infile)
|
|||
* transparent pixels will be mapped into the transparent entry.
|
||||
* There is no particularly good way around this in the case
|
||||
* that all 256 8-bit shades are used, but one could write some
|
||||
* custom 16-bit code to handle the case where there are free
|
||||
* custom 16-bit code to handle the case where there are gdFree
|
||||
* palette entries. This error will be extremely rare in
|
||||
* general, though. (Quite possibly there is only one such
|
||||
* image in existence.) */
|
||||
|
@ -248,7 +258,7 @@ gdImagePtr gdImageCreateFromPngCtx(gdIOCtx *infile)
|
|||
case PNG_COLOR_TYPE_RGB:
|
||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||
/* allocate a palette and check for single-shade transparency */
|
||||
if ((palette = (png_colorp)malloc(256*sizeof(png_color))) == NULL) {
|
||||
if ((palette = (png_colorp)gdMalloc(256*sizeof(png_color))) == NULL) {
|
||||
fprintf(stderr, "gd-png error: cannot allocate RGB palette\n");
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return NULL;
|
||||
|
@ -332,15 +342,15 @@ gdImagePtr gdImageCreateFromPngCtx(gdIOCtx *infile)
|
|||
|
||||
/* allocate space for the PNG image data */
|
||||
rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
if ((image_data = (png_bytep)malloc(rowbytes*height)) == NULL) {
|
||||
if ((image_data = (png_bytep)gdMalloc(rowbytes*height)) == NULL) {
|
||||
fprintf(stderr, "gd-png error: cannot allocate image data\n");
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return NULL;
|
||||
}
|
||||
if ((row_pointers = (png_bytepp)malloc(height*sizeof(png_bytep))) == NULL) {
|
||||
if ((row_pointers = (png_bytepp)gdMalloc(height*sizeof(png_bytep))) == NULL) {
|
||||
fprintf(stderr, "gd-png error: cannot allocate row pointers\n");
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
free(image_data);
|
||||
gdFree(image_data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -355,8 +365,8 @@ gdImagePtr gdImageCreateFromPngCtx(gdIOCtx *infile)
|
|||
if ((im = gdImageCreate((int)width, (int)height)) == NULL) {
|
||||
fprintf(stderr, "gd-png error: cannot allocate gdImage struct\n");
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
free(image_data);
|
||||
free(row_pointers);
|
||||
gdFree(image_data);
|
||||
gdFree(row_pointers);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -399,9 +409,9 @@ gdImagePtr gdImageCreateFromPngCtx(gdIOCtx *infile)
|
|||
#endif
|
||||
|
||||
if (palette_allocated)
|
||||
free(palette);
|
||||
free(image_data);
|
||||
free(row_pointers);
|
||||
gdFree(palette);
|
||||
gdFree(image_data);
|
||||
gdFree(row_pointers);
|
||||
|
||||
return im;
|
||||
}
|
||||
|
@ -444,8 +454,12 @@ void gdImagePngCtx(gdImagePtr im, gdIOCtx *outfile)
|
|||
volatile int remap = FALSE;
|
||||
|
||||
|
||||
#ifndef PNG_SETJMP_NOT_SUPPORTED
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
&gdPngJmpbufStruct, gdPngErrorHandler, NULL);
|
||||
#else
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
#endif
|
||||
if (png_ptr == NULL) {
|
||||
fprintf(stderr, "gd-png error: cannot allocate libpng main struct\n");
|
||||
return;
|
||||
|
@ -458,11 +472,13 @@ void gdImagePngCtx(gdImagePtr im, gdIOCtx *outfile)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifndef PNG_SETJMP_NOT_SUPPORTED
|
||||
if (setjmp(gdPngJmpbufStruct.jmpbuf)) {
|
||||
fprintf(stderr, "gd-png error: setjmp returns error condition\n");
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
png_set_write_fn(png_ptr, (void *)outfile, gdPngWriteData, gdPngFlushData);
|
||||
|
||||
|
@ -561,15 +577,15 @@ void gdImagePngCtx(gdImagePtr im, gdIOCtx *outfile)
|
|||
* interlaced images, but interlacing causes some serious complications. */
|
||||
if (remap) {
|
||||
png_bytep *row_pointers;
|
||||
row_pointers = malloc(sizeof(png_bytep) * height);
|
||||
row_pointers = gdMalloc(sizeof(png_bytep) * height);
|
||||
if (row_pointers == NULL) {
|
||||
fprintf(stderr, "gd-png error: unable to allocate row_pointers\n");
|
||||
}
|
||||
for (j = 0; j < height; ++j) {
|
||||
if ((row_pointers[j] = (png_bytep)malloc(width)) == NULL) {
|
||||
if ((row_pointers[j] = (png_bytep)gdMalloc(width)) == NULL) {
|
||||
fprintf(stderr, "gd-png error: unable to allocate rows\n");
|
||||
for (i = 0; i < j; ++i)
|
||||
free(row_pointers[i]);
|
||||
gdFree(row_pointers[i]);
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < width; ++i)
|
||||
|
@ -580,8 +596,8 @@ void gdImagePngCtx(gdImagePtr im, gdIOCtx *outfile)
|
|||
png_write_end(png_ptr, info_ptr);
|
||||
|
||||
for (j = 0; j < height; ++j)
|
||||
free(row_pointers[j]);
|
||||
free(row_pointers);
|
||||
gdFree(row_pointers[j]);
|
||||
gdFree(row_pointers);
|
||||
} else {
|
||||
png_write_image(png_ptr, im->pixels);
|
||||
png_write_end(png_ptr, info_ptr);
|
||||
|
@ -591,3 +607,4 @@ void gdImagePngCtx(gdImagePtr im, gdIOCtx *outfile)
|
|||
}
|
||||
|
||||
|
||||
#endif /* HAVE_LIBPNG */
|
||||
|
|
|
@ -51,12 +51,12 @@
|
|||
----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <gd.h>
|
||||
#include <gdfonts.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "gd.h"
|
||||
#include "wbmp.h"
|
||||
|
||||
|
||||
|
@ -65,7 +65,7 @@
|
|||
** Wrapper around gdPutC for use with writewbmp
|
||||
**
|
||||
*/
|
||||
int gd_putout( int i, void * out )
|
||||
void gd_putout( int i, void * out )
|
||||
{
|
||||
gdPutC( i , (gdIOCtx *) out );
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ void gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out) {
|
|||
/* write the WBMP to a gd file descriptor */
|
||||
if ( writewbmp( wbmp, &gd_putout, out ) )
|
||||
fprintf(stderr, "Could not save WBMP\n");
|
||||
/* des submitted this bugfix: free the memory. */
|
||||
/* des submitted this bugfix: gdFree the memory. */
|
||||
freewbmp(wbmp);
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ void gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out) {
|
|||
*/
|
||||
gdImagePtr gdImageCreateFromWBMPCtx( gdIOCtx *infile )
|
||||
{
|
||||
FILE *wbmp_file;
|
||||
/* FILE *wbmp_file; */
|
||||
Wbmp *wbmp;
|
||||
gdImagePtr im = NULL;
|
||||
int black, white;
|
||||
|
|
|
@ -1,4 +1,15 @@
|
|||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
|
||||
#ifdef HAVE_LIBTTF
|
||||
#define NEED_CACHE 1
|
||||
#else
|
||||
#ifdef HAVE_LIBFREETYPE
|
||||
#define NEED_CACHE 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NEED_CACHE
|
||||
|
||||
/*
|
||||
* gdcache.c
|
||||
|
@ -55,7 +66,7 @@ gdCacheCreate(
|
|||
{
|
||||
gdCache_head_t *head;
|
||||
|
||||
head = (gdCache_head_t *)malloc(sizeof(gdCache_head_t));
|
||||
head = (gdCache_head_t *)gdMalloc(sizeof(gdCache_head_t));
|
||||
head->mru = NULL;
|
||||
head->size = size;
|
||||
head->gdCacheTest = gdCacheTest;
|
||||
|
@ -74,9 +85,9 @@ gdCacheDelete( gdCache_head_t *head )
|
|||
(*(head->gdCacheRelease))(elem->userdata);
|
||||
prev = elem;
|
||||
elem = elem->next;
|
||||
free((char *)prev);
|
||||
gdFree((char *)prev);
|
||||
}
|
||||
free((char *)head);
|
||||
gdFree((char *)head);
|
||||
}
|
||||
|
||||
void *
|
||||
|
@ -108,7 +119,7 @@ gdCacheGet( gdCache_head_t *head, void *keydata )
|
|||
return NULL;
|
||||
}
|
||||
if (i < head->size) { /* cache still growing - add new elem */
|
||||
elem = (gdCache_element_t *)malloc(sizeof(gdCache_element_t));
|
||||
elem = (gdCache_element_t *)gdMalloc(sizeof(gdCache_element_t));
|
||||
}
|
||||
else { /* cache full - replace least-recently-used */
|
||||
/* preveprev becomes new end of list */
|
||||
|
@ -150,7 +161,7 @@ cacheFetch( char **error, void *key )
|
|||
{
|
||||
key_value_t *map;
|
||||
|
||||
map = (key_value_t *)malloc(sizeof(key_value_t));
|
||||
map = (key_value_t *)gdMalloc(sizeof(key_value_t));
|
||||
map->key = *(int *)key;
|
||||
map->value = 3;
|
||||
|
||||
|
@ -161,7 +172,7 @@ cacheFetch( char **error, void *key )
|
|||
static void
|
||||
cacheRelease( void *map)
|
||||
{
|
||||
free( (char *)map );
|
||||
gdFree( (char *)map );
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -0,0 +1,762 @@
|
|||
/********************************************/
|
||||
/* gd interface to freetype library */
|
||||
/* */
|
||||
/* John Ellson ellson@lucent.com */
|
||||
/********************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
|
||||
#ifndef MSWIN32
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#define R_OK 2
|
||||
#endif
|
||||
|
||||
/* number of antialised colors for indexed bitmaps */
|
||||
#define NUMCOLORS 8
|
||||
|
||||
#ifndef HAVE_LIBFREETYPE
|
||||
char * gdImageStringFT(gdImage *im, int *brect, int fg, char *fontlist,
|
||||
double ptsize, double angle, int x, int y, char *string)
|
||||
{
|
||||
#ifdef HAVE_LIBTTF
|
||||
return gdImageStringTTF(im,brect,fg,fontlist,ptsize,angle,x,y,string);
|
||||
#else
|
||||
return "libgd was not built with FreeType font support\n";
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
|
||||
#include "gdcache.h"
|
||||
#include "freetype/freetype.h"
|
||||
#include "freetype/ftglyph.h"
|
||||
|
||||
/* number of fonts cached before least recently used is replaced */
|
||||
#define FONTCACHESIZE 6
|
||||
|
||||
/* number of antialias color lookups cached */
|
||||
#define TWEENCOLORCACHESIZE 32
|
||||
|
||||
/*
|
||||
* Line separation as a factor of font height.
|
||||
* No space between if LINESPACE = 1.00
|
||||
* Line separation will be rounded up to next pixel row.
|
||||
*/
|
||||
#define LINESPACE 1.05
|
||||
|
||||
/*
|
||||
* The character (space) used to separate alternate fonts in the
|
||||
* fontlist parameter to gdImageStringFT.
|
||||
*/
|
||||
#define LISTSEPARATOR " "
|
||||
|
||||
/*
|
||||
* DEFAULT_FONTPATH and PATHSEPARATOR are host type dependent and
|
||||
* are normally set by configure in gvconfig.h. These are just
|
||||
* some last resort values that might match some Un*x system
|
||||
* if building this version of gd separate from graphviz.
|
||||
*/
|
||||
#ifndef DEFAULT_FONTPATH
|
||||
#define DEFAULT_FONTPATH "/usr/share/fonts/truetype"
|
||||
#endif
|
||||
#ifndef PATHSEPARATOR
|
||||
#define PATHSEPARATOR ":"
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define FALSE 0
|
||||
#define TRUE !FALSE
|
||||
#endif
|
||||
|
||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||
|
||||
typedef struct {
|
||||
char *fontlist; /* key */
|
||||
FT_Library *library;
|
||||
FT_Face face;
|
||||
FT_Bool have_char_map_unicode,
|
||||
have_char_map_big5,
|
||||
have_char_map_sjis,
|
||||
have_char_map_apple_roman;
|
||||
gdCache_head_t *glyphCache;
|
||||
} font_t;
|
||||
|
||||
typedef struct {
|
||||
char *fontlist; /* key */
|
||||
FT_Library *library;
|
||||
} fontkey_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned char pixel; /* key */
|
||||
unsigned char bgcolor; /* key */
|
||||
int fgcolor; /* key */ /* -ve means no antialias */
|
||||
gdImagePtr im; /* key */
|
||||
unsigned char tweencolor;
|
||||
} tweencolor_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned char pixel; /* key */
|
||||
unsigned char bgcolor; /* key */
|
||||
int fgcolor; /* key */ /* -ve means no antialias */
|
||||
gdImagePtr im; /* key */
|
||||
} tweencolorkey_t;
|
||||
|
||||
/********************************************************************
|
||||
* gdTcl_UtfToUniChar is borrowed from Tcl ...
|
||||
*/
|
||||
/*
|
||||
* tclUtf.c --
|
||||
*
|
||||
* Routines for manipulating UTF-8 strings.
|
||||
*
|
||||
* Copyright (c) 1997-1998 Sun Microsystems, Inc.
|
||||
*
|
||||
* See the file "license.terms" for information on usage and redistribution
|
||||
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
*
|
||||
* SCCS: @(#) tclUtf.c 1.25 98/01/28 18:02:43
|
||||
*/
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------------------
|
||||
*
|
||||
* gdTcl_UtfToUniChar --
|
||||
*
|
||||
* Extract the Tcl_UniChar represented by the UTF-8 string. Bad
|
||||
* UTF-8 sequences are converted to valid Tcl_UniChars and processing
|
||||
* continues. Equivalent to Plan 9 chartorune().
|
||||
*
|
||||
* The caller must ensure that the source buffer is long enough that
|
||||
* this routine does not run off the end and dereference non-existent
|
||||
* memory looking for trail bytes. If the source buffer is known to
|
||||
* be '\0' terminated, this cannot happen. Otherwise, the caller
|
||||
* should call Tcl_UtfCharComplete() before calling this routine to
|
||||
* ensure that enough bytes remain in the string.
|
||||
*
|
||||
* Results:
|
||||
* *chPtr is filled with the Tcl_UniChar, and the return value is the
|
||||
* number of bytes from the UTF-8 string that were consumed.
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifdef JISX0208
|
||||
#include "jisx0208.h"
|
||||
#endif
|
||||
|
||||
#define Tcl_UniChar int
|
||||
#define TCL_UTF_MAX 3
|
||||
static int
|
||||
gdTcl_UtfToUniChar(char *str, Tcl_UniChar *chPtr)
|
||||
/* str is the UTF8 next character pointer */
|
||||
/* chPtr is the int for the result */
|
||||
{
|
||||
int byte;
|
||||
|
||||
/* HTML4.0 entities in decimal form, e.g. Å */
|
||||
byte = *((unsigned char *) str);
|
||||
if (byte == '&') {
|
||||
int i, n=0;
|
||||
|
||||
byte = *((unsigned char *) (str+1));
|
||||
if (byte == '#') {
|
||||
for (i = 2; i < 8; i++) {
|
||||
byte = *((unsigned char *) (str+i));
|
||||
if (byte >= '0' && byte <= '9') {
|
||||
n = (n * 10) + (byte - '0');
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (byte == ';') {
|
||||
*chPtr = (Tcl_UniChar) n;
|
||||
return ++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Unroll 1 to 3 byte UTF-8 sequences, use loop to handle longer ones.
|
||||
*/
|
||||
|
||||
byte = *((unsigned char *) str);
|
||||
#ifdef JISX0208
|
||||
if (0xA1 <= byte && byte <= 0xFE) {
|
||||
int jiscode, ku, ten;
|
||||
|
||||
jiscode = 0x100 * (byte & 0x7F) + (str[1] & 0x7F);
|
||||
ku = (jiscode >> 8) - 0x20;
|
||||
ten = (jiscode % 256) - 0x20;
|
||||
if ( (ku < 1 || ku > 92) || (ten < 1 || ten > 94) ) {
|
||||
*chPtr = (Tcl_UniChar) byte;
|
||||
return 1;
|
||||
}
|
||||
|
||||
*chPtr = (Tcl_UniChar) UnicodeTbl[ku - 1][ten - 1];
|
||||
return 2;
|
||||
} else
|
||||
#endif /* JISX0208 */
|
||||
if (byte < 0xC0) {
|
||||
/*
|
||||
* Handles properly formed UTF-8 characters between
|
||||
* 0x01 and 0x7F. Also treats \0 and naked trail
|
||||
* bytes 0x80 to 0xBF as valid characters representing
|
||||
* themselves.
|
||||
*/
|
||||
|
||||
*chPtr = (Tcl_UniChar) byte;
|
||||
return 1;
|
||||
} else if (byte < 0xE0) {
|
||||
if ((str[1] & 0xC0) == 0x80) {
|
||||
/*
|
||||
* Two-byte-character lead-byte followed
|
||||
* by a trail-byte.
|
||||
*/
|
||||
|
||||
*chPtr = (Tcl_UniChar) (((byte & 0x1F) << 6)
|
||||
| (str[1] & 0x3F));
|
||||
return 2;
|
||||
}
|
||||
/*
|
||||
* A two-byte-character lead-byte not followed by trail-byte
|
||||
* represents itself.
|
||||
*/
|
||||
|
||||
*chPtr = (Tcl_UniChar) byte;
|
||||
return 1;
|
||||
} else if (byte < 0xF0) {
|
||||
if (((str[1] & 0xC0) == 0x80) && ((str[2] & 0xC0) == 0x80)) {
|
||||
/*
|
||||
* Three-byte-character lead byte followed by
|
||||
* two trail bytes.
|
||||
*/
|
||||
|
||||
*chPtr = (Tcl_UniChar) (((byte & 0x0F) << 12)
|
||||
| ((str[1] & 0x3F) << 6) | (str[2] & 0x3F));
|
||||
return 3;
|
||||
}
|
||||
/*
|
||||
* A three-byte-character lead-byte not followed by
|
||||
* two trail-bytes represents itself.
|
||||
*/
|
||||
|
||||
*chPtr = (Tcl_UniChar) byte;
|
||||
return 1;
|
||||
}
|
||||
#if TCL_UTF_MAX > 3
|
||||
else {
|
||||
int ch, total, trail;
|
||||
|
||||
total = totalBytes[byte];
|
||||
trail = total - 1;
|
||||
if (trail > 0) {
|
||||
ch = byte & (0x3F >> trail);
|
||||
do {
|
||||
str++;
|
||||
if ((*str & 0xC0) != 0x80) {
|
||||
*chPtr = byte;
|
||||
return 1;
|
||||
}
|
||||
ch <<= 6;
|
||||
ch |= (*str & 0x3F);
|
||||
trail--;
|
||||
} while (trail > 0);
|
||||
*chPtr = ch;
|
||||
return total;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
*chPtr = (Tcl_UniChar) byte;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
/* font cache functions */
|
||||
|
||||
static int
|
||||
fontTest ( void *element, void *key )
|
||||
{
|
||||
font_t *a=(font_t *)element;
|
||||
fontkey_t *b=(fontkey_t *)key;
|
||||
|
||||
return (strcmp(a->fontlist, b->fontlist) == 0);
|
||||
}
|
||||
|
||||
static void *
|
||||
fontFetch ( char **error, void *key )
|
||||
{
|
||||
font_t *a;
|
||||
fontkey_t *b=(fontkey_t *)key;
|
||||
int n;
|
||||
int font_found=0;
|
||||
unsigned short platform, encoding;
|
||||
char *fontsearchpath, *fontpath, *fontlist;
|
||||
char *fullname = NULL;
|
||||
char *name, *path, *dir;
|
||||
char *strtok_ptr;
|
||||
FT_Error err;
|
||||
FT_CharMap found=0;
|
||||
FT_CharMap charmap;
|
||||
|
||||
a = (font_t *)gdMalloc(sizeof(font_t));
|
||||
a->fontlist = strdup(b->fontlist);
|
||||
a->library = b->library;
|
||||
|
||||
/*
|
||||
* Search the pathlist for any of a list of font names.
|
||||
*/
|
||||
fontsearchpath = getenv("GDFONTPATH");
|
||||
if (! fontsearchpath ) fontsearchpath = DEFAULT_FONTPATH;
|
||||
path = strdup(fontsearchpath);
|
||||
fontlist = strdup(a->fontlist);
|
||||
|
||||
/*
|
||||
* Must use gd_strtok_r else pointer corrupted by strtok in nested loop.
|
||||
*/
|
||||
for (name = gd_strtok_r(fontlist,LISTSEPARATOR,&strtok_ptr); name;
|
||||
name = gd_strtok_r(0,LISTSEPARATOR,&strtok_ptr)) {
|
||||
|
||||
/*
|
||||
* Allocate an oversized buffer that is guaranteed to be
|
||||
* big enough for all paths to be tested.
|
||||
*/
|
||||
fullname = gdRealloc(fullname,
|
||||
strlen(fontsearchpath) + strlen(name) + 6);
|
||||
/* if name is an absolute filename then test directly */
|
||||
if (*name == '/') {
|
||||
sprintf(fullname,"%s",name);
|
||||
if (access(fullname,R_OK) == 0) {font_found++; break;}
|
||||
}
|
||||
for (dir = strtok(path,PATHSEPARATOR); dir;
|
||||
dir = strtok(0,PATHSEPARATOR)) {
|
||||
sprintf(fullname,"%s/%s.ttf",dir,name);
|
||||
if (access(fullname,R_OK) == 0) {font_found++; break;}
|
||||
}
|
||||
if (font_found) break;
|
||||
}
|
||||
gdFree(path);
|
||||
gdFree(fontlist);
|
||||
if (! font_found) {
|
||||
*error = "Could not find/open font";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err = FT_New_Face(*b->library, fullname, 0, &a->face);
|
||||
if (err) {
|
||||
*error = "Could not read font";
|
||||
return NULL;
|
||||
}
|
||||
gdFree(fullname);
|
||||
|
||||
/* FIXME - This mapping stuff is imcomplete - where is the spec? */
|
||||
|
||||
a->have_char_map_unicode = 0;
|
||||
a->have_char_map_big5 = 0;
|
||||
a->have_char_map_sjis = 0;
|
||||
a->have_char_map_apple_roman = 0;
|
||||
for (n = 0; n < a->face->num_charmaps; n++) {
|
||||
charmap = a->face->charmaps[n];
|
||||
platform = charmap->platform_id;
|
||||
encoding = charmap->encoding_id;
|
||||
if ((platform == 3 && encoding == 1) /* Windows Unicode */
|
||||
|| (platform == 3 && encoding == 0) /* Windows Symbol */
|
||||
|| (platform == 2 && encoding == 1) /* ISO Unicode */
|
||||
|| (platform == 0)) { /* Apple Unicode */
|
||||
a->have_char_map_unicode = 1;
|
||||
found = charmap;
|
||||
} else
|
||||
if (platform == 3 && encoding == 4) { /* Windows Big5 */
|
||||
a->have_char_map_big5 = 1;
|
||||
found = charmap;
|
||||
} else
|
||||
if (platform == 3 && encoding == 2) { /* Windows Sjis */
|
||||
a->have_char_map_sjis = 1;
|
||||
found = charmap;
|
||||
} else
|
||||
if ((platform == 1 && encoding == 0) /* Apple Roman */
|
||||
|| (platform == 2 && encoding == 0)) { /* ISO ASCII */
|
||||
a->have_char_map_apple_roman = 1;
|
||||
found = charmap;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
*error = "Unable to find a CharMap that I can handle";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (void *)a;
|
||||
}
|
||||
|
||||
static void
|
||||
fontRelease( void *element )
|
||||
{
|
||||
font_t *a=(font_t *)element;
|
||||
|
||||
FT_Done_Face(a->face);
|
||||
gdFree(a->fontlist);
|
||||
gdFree( (char *)element );
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
/* tweencolor cache functions */
|
||||
|
||||
static int
|
||||
tweenColorTest (void *element, void *key)
|
||||
{
|
||||
tweencolor_t *a=(tweencolor_t *)element;
|
||||
tweencolorkey_t *b=(tweencolorkey_t *)key;
|
||||
|
||||
return (a->pixel == b->pixel
|
||||
&& a->bgcolor == b->bgcolor
|
||||
&& a->fgcolor == b->fgcolor
|
||||
&& a->im == b->im);
|
||||
}
|
||||
|
||||
/*
|
||||
* Computes a color in im's color table that is part way between
|
||||
* the background and foreground colors proportional to the gray
|
||||
* pixel value in the range 0-NUMCOLORS. The fg and bg colors must already
|
||||
* be in the color table.
|
||||
*/
|
||||
static void *
|
||||
tweenColorFetch (char **error, void *key)
|
||||
{
|
||||
tweencolor_t *a;
|
||||
tweencolorkey_t *b=(tweencolorkey_t *)key;
|
||||
int pixel, npixel, bg, fg;
|
||||
gdImagePtr im;
|
||||
|
||||
a = (tweencolor_t *)gdMalloc(sizeof(tweencolor_t));
|
||||
pixel = a->pixel = b->pixel;
|
||||
bg = a->bgcolor = b->bgcolor;
|
||||
fg = a->fgcolor = b->fgcolor;
|
||||
im = b->im;
|
||||
|
||||
/* if fg is specified by a negative color idx, then don't antialias */
|
||||
if (fg <0) {
|
||||
a->tweencolor = -fg;
|
||||
} else {
|
||||
npixel = NUMCOLORS - pixel;
|
||||
a->tweencolor = gdImageColorResolve(im,
|
||||
(pixel * im->red[fg] + npixel * im->red[bg]) / NUMCOLORS,
|
||||
(pixel * im->green[fg] + npixel * im->green[bg]) / NUMCOLORS,
|
||||
(pixel * im->blue[fg] + npixel * im->blue[bg]) / NUMCOLORS);
|
||||
}
|
||||
return (void *)a;
|
||||
}
|
||||
|
||||
static void
|
||||
tweenColorRelease(void *element)
|
||||
{
|
||||
gdFree((char *)element);
|
||||
}
|
||||
|
||||
/* draw_bitmap - transfers glyph bitmap to GD image */
|
||||
static char *
|
||||
gdft_draw_bitmap(gdImage *im, int fg, FT_Bitmap bitmap, int pen_x, int pen_y) {
|
||||
char *pixel;
|
||||
int x, y, row, col, pc;
|
||||
|
||||
tweencolor_t *tc_elem;
|
||||
tweencolorkey_t tc_key;
|
||||
|
||||
/* initialize tweenColorCache on first call */
|
||||
static gdCache_head_t *tc_cache;
|
||||
|
||||
if ( ! tc_cache ) {
|
||||
tc_cache = gdCacheCreate(TWEENCOLORCACHESIZE,
|
||||
tweenColorTest, tweenColorFetch, tweenColorRelease);
|
||||
}
|
||||
|
||||
/* copy to gif, mapping colors */
|
||||
tc_key.fgcolor = fg;
|
||||
tc_key.im = im;
|
||||
for (row = 0; row < bitmap.rows; row++) {
|
||||
pc = row * bitmap.pitch;
|
||||
y = pen_y + row;
|
||||
|
||||
/* clip if out of bounds */
|
||||
if (y >= im->sy || y < 0) continue;
|
||||
|
||||
for (col = 0; col < bitmap.width; col++, pc++) {
|
||||
if (bitmap.pixel_mode == ft_pixel_mode_grays) {
|
||||
/*
|
||||
* Round to NUMCOLORS levels of antialiasing for
|
||||
* index color images since only 256 colors are
|
||||
* available.
|
||||
*/
|
||||
tc_key.pixel = ((bitmap.buffer[pc] * NUMCOLORS)
|
||||
+ bitmap.num_grays/2)
|
||||
/ (bitmap.num_grays - 1);
|
||||
} else
|
||||
if (bitmap.pixel_mode == ft_pixel_mode_mono) {
|
||||
tc_key.pixel = ((bitmap.buffer[pc/8]
|
||||
<< (pc%8)) & 128) ? NUMCOLORS : 0;
|
||||
} else {
|
||||
return "Unsupported ft_pixel_mode";
|
||||
}
|
||||
|
||||
if (tc_key.pixel > 0) { /* if not background */
|
||||
x = pen_x + col;
|
||||
|
||||
/* clip if out of bounds */
|
||||
if (x >= im->sx || x < 0) continue;
|
||||
|
||||
/* get pixel location in gd buffer */
|
||||
pixel = &im->pixels[y][x];
|
||||
if (tc_key.pixel == NUMCOLORS) {
|
||||
/* use fg color directly */
|
||||
*pixel = fg;
|
||||
} else {
|
||||
/* find antialised color */
|
||||
tc_key.bgcolor = *pixel;
|
||||
tc_elem = (tweencolor_t *)gdCacheGet(
|
||||
tc_cache, &tc_key);
|
||||
*pixel = tc_elem->tweencolor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (char *)NULL;
|
||||
}
|
||||
|
||||
extern int any2eucjp(char *, char *, unsigned int);
|
||||
|
||||
/********************************************************************/
|
||||
/* gdImageStringFT - render a utf8 string onto a gd image */
|
||||
|
||||
char * gdImageStringFT(gdImage *im, int *brect, int fg, char *fontlist,
|
||||
double ptsize, double angle, int x, int y, char *string)
|
||||
{
|
||||
FT_F26Dot6 ur_x=0, ur_y=0, ll_x=0, ll_y=0;
|
||||
FT_F26Dot6 advance_x, advance_y;
|
||||
FT_BBox bbox;
|
||||
FT_Matrix matrix;
|
||||
FT_Vector pen, delta;
|
||||
FT_Face face;
|
||||
FT_Glyph image;
|
||||
FT_GlyphSlot slot;
|
||||
FT_Error err;
|
||||
FT_Bool use_kerning;
|
||||
FT_UInt glyph_index, previous;
|
||||
double sin_a = sin(angle);
|
||||
double cos_a = cos(angle);
|
||||
int len, i=0, ch;
|
||||
int x1=0, y1=0;
|
||||
font_t *font;
|
||||
fontkey_t fontkey;
|
||||
char *next;
|
||||
char *tmpstr = 0;
|
||||
|
||||
/***** initialize font library and font cache on first call ******/
|
||||
static gdCache_head_t *fontCache;
|
||||
static FT_Library library;
|
||||
|
||||
if (! fontCache) {
|
||||
if (FT_Init_FreeType(&library)) {
|
||||
return "Failure to initialize font library";
|
||||
}
|
||||
fontCache = gdCacheCreate( FONTCACHESIZE,
|
||||
fontTest, fontFetch, fontRelease);
|
||||
}
|
||||
/*****/
|
||||
|
||||
/* get the font (via font cache) */
|
||||
fontkey.fontlist = fontlist;
|
||||
fontkey.library = &library;
|
||||
font = (font_t *)gdCacheGet(fontCache, &fontkey);
|
||||
if (! font) {
|
||||
return fontCache->error;
|
||||
}
|
||||
face = font->face; /* shortcut */
|
||||
slot = face->glyph; /* shortcut */
|
||||
|
||||
if (FT_Set_Char_Size(face, 0, (FT_F26Dot6)(ptsize*64),
|
||||
GD_RESOLUTION, GD_RESOLUTION)) {
|
||||
return "Could not set character size";
|
||||
}
|
||||
|
||||
matrix.xx = (FT_Fixed) (cos_a * (1<<16));
|
||||
matrix.yx = (FT_Fixed) (sin_a * (1<<16));
|
||||
matrix.xy = - matrix.yx;
|
||||
matrix.yy = matrix.xx;
|
||||
|
||||
pen.x = pen.y = 0; /* running position of rotated string */
|
||||
|
||||
use_kerning = FT_HAS_KERNING(face);
|
||||
previous = 0;
|
||||
|
||||
advance_x = advance_y = 0; /* running position (26.6) of right string */
|
||||
|
||||
#ifndef JISX0208
|
||||
if (font->have_char_map_sjis) {
|
||||
#endif
|
||||
if (tmpstr = (char *)gdMalloc(BUFSIZ)) {
|
||||
any2eucjp(tmpstr, string, BUFSIZ);
|
||||
next=tmpstr;
|
||||
} else {
|
||||
next=string;
|
||||
}
|
||||
#ifndef JISX0208
|
||||
} else {
|
||||
next=string;
|
||||
}
|
||||
#endif
|
||||
while (*next) {
|
||||
ch = *next;
|
||||
|
||||
/* carriage returns */
|
||||
if (ch == '\r') {
|
||||
advance_x = 0;
|
||||
x1 = (advance_x * cos_a - advance_y * sin_a + 32) / 64;
|
||||
y1 = (advance_x * sin_a + advance_y * cos_a + 32) / 64;
|
||||
pen.x = pen.y = 0;
|
||||
previous = 0; /* clear kerning flag */
|
||||
next++;
|
||||
continue;
|
||||
}
|
||||
/* newlines */
|
||||
if (ch == '\n') {
|
||||
advance_y -= face->size->metrics.height * LINESPACE;
|
||||
advance_y = (advance_y-32) & -64; /* round to next pixel row */
|
||||
x1 = (advance_x * cos_a - advance_y * sin_a + 32) / 64;
|
||||
y1 = (advance_x * sin_a + advance_y * cos_a + 32) / 64;
|
||||
pen.x = pen.y = 0;
|
||||
previous = 0; /* clear kerning flag */
|
||||
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++;
|
||||
ch = (ch - 0x21) / 2 + 0x81;
|
||||
if (ch >= 0xA0) ch += 0x40;
|
||||
|
||||
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++;
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
FT_Set_Transform(face, &matrix, &pen);
|
||||
|
||||
/* Convert character code to glyph index */
|
||||
glyph_index = FT_Get_Char_Index( face, ch );
|
||||
|
||||
/* retieve kerning distance and move pen position */
|
||||
if ( use_kerning && previous && glyph_index ) {
|
||||
FT_Get_Kerning( face, previous, glyph_index,
|
||||
ft_kerning_default, &delta );
|
||||
pen.x += delta.x >> 6;
|
||||
}
|
||||
|
||||
/* load glyph image into the slot (erase previous one) */
|
||||
err = FT_Load_Glyph(face, glyph_index, FT_LOAD_RENDER);
|
||||
if (err) {
|
||||
return "Problem loading glyph";
|
||||
}
|
||||
|
||||
/* if null *im, or invalid color,
|
||||
then assume user just wants brect */
|
||||
if (im && fg <= 255 && fg >= -255) {
|
||||
|
||||
/* now, draw to our target surface */
|
||||
gdft_draw_bitmap(im, fg, slot->bitmap,
|
||||
x + x1 + pen.x + slot->bitmap_left,
|
||||
y - y1 + pen.y - slot->bitmap_top);
|
||||
}
|
||||
|
||||
/* increment pen position */
|
||||
pen.x += slot->advance.x >> 6;
|
||||
pen.y -= slot->advance.y >> 6;
|
||||
|
||||
/* record current glyph index for kerning */
|
||||
previous = glyph_index;
|
||||
|
||||
if (brect) { /* only if need brect */
|
||||
if (! i++) { /* if first character, init BB corner values */
|
||||
ll_x = slot->metrics.horiBearingX;
|
||||
ll_y = slot->metrics.horiBearingY - slot->metrics.height;
|
||||
ur_x = slot->metrics.horiBearingX + slot->metrics.width;
|
||||
ur_y = slot->metrics.horiBearingY;
|
||||
}
|
||||
else {
|
||||
if (! advance_x) ll_x = MIN(slot->metrics.horiBearingX, ll_x);
|
||||
ll_y = MIN(advance_y + slot->metrics.horiBearingY - slot->metrics.height, ll_y);
|
||||
ur_x = MAX(advance_x + slot->metrics.horiBearingX + slot->metrics.width, ur_x);
|
||||
if (! advance_y) ur_y = MAX(slot->metrics.horiBearingY, ur_y);
|
||||
}
|
||||
}
|
||||
|
||||
advance_x += slot->metrics.horiAdvance;
|
||||
}
|
||||
|
||||
if (brect) { /* only if need brect */
|
||||
/* rotate bounding rectangle */
|
||||
brect[0] = (int)(ll_x * cos_a - ll_y * sin_a);
|
||||
brect[1] = (int)(ll_x * sin_a + ll_y * cos_a);
|
||||
brect[2] = (int)(ur_x * cos_a - ll_y * sin_a);
|
||||
brect[3] = (int)(ur_x * sin_a + ll_y * cos_a);
|
||||
brect[4] = (int)(ur_x * cos_a - ur_y * sin_a);
|
||||
brect[5] = (int)(ur_x * sin_a + ur_y * cos_a);
|
||||
brect[6] = (int)(ll_x * cos_a - ur_y * sin_a);
|
||||
brect[7] = (int)(ll_x * sin_a + ur_y * cos_a);
|
||||
|
||||
/* scale, round and offset brect */
|
||||
i = 0;
|
||||
while (i<8) {
|
||||
brect[i] = x + (brect[i] + 32) / 64;
|
||||
i++;
|
||||
brect[i] = y - (brect[i] + 32) / 64;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( tmpstr ) gdFree(tmpstr);
|
||||
return (char *)NULL;
|
||||
}
|
||||
|
||||
#endif /* HAVE_LIBFREETYPE */
|
|
@ -0,0 +1,79 @@
|
|||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/* TBB: gd_strtok_r is not portable; provide an implementation */
|
||||
|
||||
#define SEP_TEST (separators[*((unsigned char *) s)])
|
||||
|
||||
char *gd_strtok_r(char *s, char *sep, char **state)
|
||||
{
|
||||
char separators[256];
|
||||
char *start;
|
||||
char *result = 0;
|
||||
memset(separators, 0, sizeof(separators));
|
||||
while (*sep) {
|
||||
separators[*((unsigned char *) sep)] = 1;
|
||||
sep++;
|
||||
}
|
||||
if (!s) {
|
||||
/* Pick up where we left off */
|
||||
s = *state;
|
||||
}
|
||||
start = s;
|
||||
/* 1. EOS */
|
||||
if (!(*s)) {
|
||||
*state = s;
|
||||
return 0;
|
||||
}
|
||||
/* 2. Leading separators, if any */
|
||||
if (SEP_TEST) {
|
||||
do {
|
||||
s++;
|
||||
} while (SEP_TEST);
|
||||
/* 2a. EOS after separators only */
|
||||
if (!(*s)) {
|
||||
*state = s;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* 3. A token */
|
||||
result = s;
|
||||
do {
|
||||
/* 3a. Token at end of string */
|
||||
if (!(*s)) {
|
||||
*state = s;
|
||||
return result;
|
||||
}
|
||||
s++;
|
||||
} while (!SEP_TEST);
|
||||
/* 4. Terminate token and skip trailing separators */
|
||||
*s = '\0';
|
||||
do {
|
||||
s++;
|
||||
} while (SEP_TEST);
|
||||
/* 5. Return token */
|
||||
*state = s;
|
||||
return result;
|
||||
}
|
||||
|
||||
void *gdCalloc(size_t nmemb, size_t size)
|
||||
{
|
||||
return calloc(nmemb, size);
|
||||
}
|
||||
|
||||
void *gdMalloc(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *gdRealloc(void *ptr, size_t size)
|
||||
{
|
||||
return realloc(ptr, size);
|
||||
}
|
||||
|
||||
void gdFree(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef GDHELPERS_H
|
||||
#define GDHELPERS_H 1
|
||||
|
||||
/* TBB: strtok_r is not universal; provide an implementation of it. */
|
||||
|
||||
extern char *gd_strtok_r(char *s, char *sep, char **state);
|
||||
|
||||
/* These functions wrap memory management. gdFree is
|
||||
in gd.h, where callers can utilize it to correctly
|
||||
free memory allocated by these functions with the
|
||||
right version of free(). */
|
||||
void *gdCalloc(size_t nmemb, size_t size);
|
||||
void *gdMalloc(size_t size);
|
||||
void *gdRealloc(void *ptr, size_t size);
|
||||
|
||||
#endif /* GDHELPERS_H */
|
||||
|
|
@ -4,6 +4,9 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
|
||||
#ifdef HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
@ -285,6 +288,9 @@ int *p1, *p2;
|
|||
if (handaku && *p2 >= 110 && *p2 <= 122) (*p2) += 2;
|
||||
}
|
||||
|
||||
/* Recast strcpy to handle unsigned chars used below. */
|
||||
#define ustrcpy(A,B) (strcpy((char*)(A),(const char*)(B)))
|
||||
|
||||
#ifdef __STDC__
|
||||
static void do_convert(unsigned char *to, unsigned char *from, const char *code)
|
||||
#else
|
||||
|
@ -387,7 +393,7 @@ char *code;
|
|||
|
||||
if (j >= BUFSIZ) {
|
||||
error("output buffer overflow at do_convert()");
|
||||
strcpy(to, from);
|
||||
ustrcpy(to, from);
|
||||
} else
|
||||
to[j] = '\0';
|
||||
#endif /* HAVE_ICONV */
|
||||
|
@ -420,12 +426,12 @@ unsigned char *to, *from;
|
|||
case NEC:
|
||||
debug("Kanji code is NEC Kanji.");
|
||||
error("cannot convert NEC Kanji.");
|
||||
strcpy(tmp, from);
|
||||
ustrcpy(tmp, from);
|
||||
kanji = FALSE;
|
||||
break;
|
||||
case EUC:
|
||||
debug("Kanji code is EUC.");
|
||||
strcpy(tmp, from);
|
||||
ustrcpy(tmp, from);
|
||||
break;
|
||||
case SJIS:
|
||||
debug("Kanji code is SJIS.");
|
||||
|
@ -433,17 +439,17 @@ unsigned char *to, *from;
|
|||
break;
|
||||
case EUCORSJIS:
|
||||
debug("Kanji code is EUC or SJIS.");
|
||||
strcpy(tmp, from);
|
||||
ustrcpy(tmp, from);
|
||||
kanji = FALSE;
|
||||
break;
|
||||
case ASCII:
|
||||
debug("This is ASCII string.");
|
||||
strcpy(tmp, from);
|
||||
ustrcpy(tmp, from);
|
||||
kanji = FALSE;
|
||||
break;
|
||||
default:
|
||||
debug("This string includes unknown code.");
|
||||
strcpy(tmp, from);
|
||||
ustrcpy(tmp, from);
|
||||
kanji = FALSE;
|
||||
break;
|
||||
}
|
||||
|
@ -469,11 +475,11 @@ unsigned char *to, *from;
|
|||
|
||||
if (j >= BUFSIZ) {
|
||||
error("output buffer overflow at Hankaku --> Zenkaku");
|
||||
strcpy(to, tmp);
|
||||
ustrcpy(to, tmp);
|
||||
} else
|
||||
to[j] = '\0';
|
||||
} else
|
||||
strcpy(to, tmp);
|
||||
ustrcpy(to, tmp);
|
||||
|
||||
return kanji;
|
||||
}
|
||||
|
@ -500,10 +506,10 @@ unsigned int dest_max;
|
|||
ret = do_check_and_conv(tmp_dest, src);
|
||||
if (strlen((const char *)tmp_dest) >= dest_max) {
|
||||
error("output buffer overflow");
|
||||
strcpy(dest, src);
|
||||
ustrcpy(dest, src);
|
||||
return -1;
|
||||
}
|
||||
strcpy(dest, tmp_dest);
|
||||
ustrcpy(dest, tmp_dest);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -518,10 +524,10 @@ unsigned char *s;
|
|||
unsigned char *t;
|
||||
unsigned int i;
|
||||
|
||||
t = (unsigned char *)malloc(BUFSIZ);
|
||||
t = (unsigned char *)gdMalloc(BUFSIZ);
|
||||
any2eucjp(t, s, BUFSIZ);
|
||||
i = strlen(t);
|
||||
free(t);
|
||||
gdFree(t);
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
@ -540,12 +546,12 @@ int main()
|
|||
printf("input : %d bytes\n", strlen(input));
|
||||
printf("output: %d bytes\n", strwidth(input));
|
||||
|
||||
output = (unsigned char *)malloc(BUFSIZ);
|
||||
output = (unsigned char *)gdMalloc(BUFSIZ);
|
||||
any2eucjp(output, input, BUFSIZ);
|
||||
str = output;
|
||||
while(*str != '\0') putchar(*(str++));
|
||||
putchar('\n');
|
||||
free(output);
|
||||
gdFree(output);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
#include "gd.h"
|
||||
#include <string.h>
|
||||
|
||||
#define PI 3.141592
|
||||
#define DEG2RAD(x) ((x)*PI/180.)
|
||||
|
||||
#define MAX(x,y) ((x) > (y) ? (x) : (y))
|
||||
#define MIN(x,y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
#define MAX4(x,y,z,w) \
|
||||
((MAX((x),(y))) > (MAX((z),(w))) ? (MAX((x),(y))) : (MAX((z),(w))))
|
||||
#define MIN4(x,y,z,w) \
|
||||
((MIN((x),(y))) < (MIN((z),(w))) ? (MIN((x),(y))) : (MIN((z),(w))))
|
||||
|
||||
#define MAXX(x) MAX4(x[0],x[2],x[4],x[6])
|
||||
#define MINX(x) MIN4(x[0],x[2],x[4],x[6])
|
||||
#define MAXY(x) MAX4(x[1],x[3],x[5],x[7])
|
||||
#define MINY(x) MIN4(x[1],x[3],x[5],x[7])
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifndef HAVE_LIBFREETYPE
|
||||
fprintf(stderr, "gd was not compiled with HAVE_LIBFREETYPE defined.\n");
|
||||
fprintf(stderr, "Install the FreeType library, including the\n");
|
||||
fprintf(stderr, "header files. Then edit the gd Makefile, type\n");
|
||||
fprintf(stderr, "make clean, and type make again.\n");
|
||||
return 1;
|
||||
#else
|
||||
gdImagePtr im;
|
||||
int black;
|
||||
int white;
|
||||
int brect[8];
|
||||
int x, y;
|
||||
char *err;
|
||||
FILE *out;
|
||||
#ifdef JISX0208
|
||||
char *s = "Hello. ‚±‚ñ‚É‚¿‚Í Qyjpqg,"; /* String to draw. */
|
||||
#else
|
||||
char *s = "Hello. Qyjpqg,"; /* String to draw. */
|
||||
#endif
|
||||
|
||||
double sz = 40.;
|
||||
|
||||
#if 0
|
||||
double angle = 0.;
|
||||
#else
|
||||
double angle = DEG2RAD(-90);
|
||||
#endif
|
||||
|
||||
#ifdef JISX0208
|
||||
char *f = "/usr/openwin/lib/locale/ja/X11/fonts/TT/HG-MinchoL.ttf"; /* UNICODE */
|
||||
/* char *f = "/usr/local/lib/fonts/truetype/DynaFont/dfpop1.ttf"; */ /* SJIS */
|
||||
#else
|
||||
char *f = "times"; /* TrueType font */
|
||||
#endif
|
||||
|
||||
/* obtain brect so that we can size the image */
|
||||
err = gdImageStringFT((gdImagePtr)NULL,&brect[0],0,f,sz,angle,0,0,s);
|
||||
if (err) {fprintf(stderr,err); return 1;}
|
||||
|
||||
/* create an image just big enough for the string */
|
||||
x = MAXX(brect) - MINX(brect) + 6;
|
||||
y = MAXY(brect) - MINY(brect) + 6;
|
||||
#if 0
|
||||
im = gdImageCreate(500,500);
|
||||
#else
|
||||
im = gdImageCreate(x,y);
|
||||
#endif
|
||||
|
||||
/* Background color (first allocated) */
|
||||
white = gdImageColorResolve(im, 255, 255, 255);
|
||||
black = gdImageColorResolve(im, 0, 0, 0);
|
||||
|
||||
/* render the string, offset origin to center string*/
|
||||
x = 0 - MINX(brect) + 3;
|
||||
y = 0 - MINY(brect) + 3;
|
||||
|
||||
err = gdImageStringFT(im,NULL,black,f,sz,angle,x,y,s);
|
||||
if (err) {fprintf(stderr,err); return 1;}
|
||||
/* TBB: Write img to test/fttest.png */
|
||||
out = fopen("test/fttest.png", "wb");
|
||||
if (!out) {
|
||||
fprintf(stderr, "Can't create test/fttest.png\n");
|
||||
exit(1);
|
||||
}
|
||||
gdImagePng(im, out);
|
||||
fclose(out);
|
||||
fprintf(stderr, "Test image written to test/fttest.png\n");
|
||||
/* Destroy it */
|
||||
gdImageDestroy(im);
|
||||
|
||||
return 0;
|
||||
#endif /* HAVE_FREETYPE */
|
||||
}
|
|
@ -32,7 +32,7 @@ int main(int argc, char *argv[])
|
|||
int brect[8];
|
||||
int x, y;
|
||||
char *err;
|
||||
|
||||
FILE *out;
|
||||
#ifdef JISX0208
|
||||
char *s = "Hello. ‚±‚ñ‚É‚¿‚Í Qyjpqg,"; /* String to draw. */
|
||||
#else
|
||||
|
@ -47,6 +47,11 @@ int main(int argc, char *argv[])
|
|||
char *f = "/usr/local/lib/fonts/truetype/misc/times.ttf"; /* TrueType font */
|
||||
#endif
|
||||
|
||||
fprintf(stderr, "HEY! THIS IS FOR THE FREETYPE 1.x LIBRARY.\n\n");
|
||||
fprintf(stderr, "For better results, look at 'gdtestft' and the\n");
|
||||
fprintf(stderr, "new gdImageStringFT function, which uses\n");
|
||||
fprintf(stderr, "the new FreeType 2.x library.\n\n");
|
||||
|
||||
/* obtain brect so that we can size the image */
|
||||
err = gdImageStringTTF((gdImagePtr)NULL,&brect[0],0,f,sz,angle,0,0,s);
|
||||
if (err) {fprintf(stderr,err); return 1;}
|
||||
|
@ -66,8 +71,16 @@ int main(int argc, char *argv[])
|
|||
err = gdImageStringTTF(im,&brect[0],black,f,sz,angle,x,y,s);
|
||||
if (err) {fprintf(stderr,err); return 1;}
|
||||
|
||||
/* Write img to stdout */
|
||||
gdImagePng(im, stdout);
|
||||
/* TBB: Write img to test/fttest.png */
|
||||
out = fopen("test/fttest.png", "wb");
|
||||
if (!out) {
|
||||
fprintf(stderr, "Can't create test/fttest.png\n");
|
||||
exit(1);
|
||||
}
|
||||
/* Write img to file */
|
||||
gdImagePng(im, out);
|
||||
|
||||
fclose(out);
|
||||
|
||||
/* Destroy it */
|
||||
gdImageDestroy(im);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/********************************************/
|
||||
/* gd interface to freetype library */
|
||||
/* */
|
||||
/* DEPRECATED -- backwards compatibility */
|
||||
/* */
|
||||
/* John Ellson ellson@lucent.com */
|
||||
/********************************************/
|
||||
|
||||
|
@ -706,7 +708,8 @@ gdttfchar(gdImage *im, int fg, font_t *font,
|
|||
(*next)++;
|
||||
if (ch >= 161 /* first code of JIS-8 pair */
|
||||
&& **next) { /* don't advance past '\0' */
|
||||
ch = (ch * 256) + **next;
|
||||
/* TBB: fix from Kwok Wah On: & 255 needed */
|
||||
ch = (ch * 256) + ((**next) & 255);
|
||||
(*next)++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ http://www.csn.ul.ie/~caolan
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
|
||||
#ifndef HAVE_XPM
|
||||
gdImagePtr gdImageCreateFromXpm(char *filename)
|
||||
|
@ -40,7 +41,7 @@ gdImagePtr gdImageCreateFromXpm(char *filename)
|
|||
return 0;
|
||||
|
||||
number = image.ncolors;
|
||||
colors = (int*)malloc(sizeof(int) * number);
|
||||
colors = (int*)gdMalloc(sizeof(int) * number);
|
||||
if (colors == NULL)
|
||||
return(0);
|
||||
for (i = 0; i < number; i++)
|
||||
|
@ -123,7 +124,7 @@ gdImagePtr gdImageCreateFromXpm(char *filename)
|
|||
fprintf(stderr,"ARRRGH\n");
|
||||
}
|
||||
|
||||
apixel = (char *)malloc(image.cpp+1);
|
||||
apixel = (char *)gdMalloc(image.cpp+1);
|
||||
if (apixel == NULL)
|
||||
return(0);
|
||||
apixel[image.cpp] = '\0';
|
||||
|
@ -137,8 +138,8 @@ gdImagePtr gdImageCreateFromXpm(char *filename)
|
|||
gdImageSetPixel(im,j,i,colors[k]);
|
||||
}
|
||||
}
|
||||
free(apixel);
|
||||
free(colors);
|
||||
gdFree(apixel);
|
||||
gdFree(colors);
|
||||
return(im);
|
||||
}
|
||||
#endif
|
||||
|
|
243
src/index.html
243
src/index.html
|
@ -1,18 +1,18 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>gd 1.8.3</TITLE>
|
||||
<TITLE>gd 1.8.4</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<!-- BANNER HERE -->
|
||||
<H1>gd 1.8.3</H1>
|
||||
<H1>gd 1.8.4</H1>
|
||||
<H2>A graphics library for fast image creation</H2>
|
||||
<H2>Follow this link to the
|
||||
<A HREF="http://www.boutell.com/gd/">latest version
|
||||
of this document</A>.</H2>
|
||||
<blockquote>
|
||||
<strong>HEY! READ THIS!</strong>
|
||||
gd 1.8.3 creates PNG, JPEG and WBMP images, not GIF images. This is a good
|
||||
thing. PNG is a more compact format, and full compression is
|
||||
gd 1.8.4 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 well with photographic images, and is still
|
||||
more compatible with the major Web browsers than even PNG is. WBMP is
|
||||
intended for wireless devices (not regular web browsers). Existing
|
||||
|
@ -22,22 +22,24 @@ version of GD.</strong> Unisys holds a patent on the LZW compression
|
|||
algorithm, which is used in fully compressed GIF images. The best
|
||||
solution is to move to legally unencumbered, well-compressed,
|
||||
modern image formats such as PNG and JPEG as soon as possible.
|
||||
|
||||
<p>
|
||||
gd 1.8.3 <strong>requires</strong> that the following libraries
|
||||
gd 1.8.4 <strong>requires</strong> that the following libraries
|
||||
also be installed:
|
||||
<p>
|
||||
libpng
|
||||
<p>
|
||||
jpeg-6b or later
|
||||
libpng (see the <a href="http://www.libpng.org/pub/png/">libpng home page</a>)
|
||||
<p>
|
||||
zlib (see the <a href="http://www.info-zip.org/pub/infozip/zlib/">info-zip home page</a>)
|
||||
zlib
|
||||
<p>
|
||||
jpeg-6b or later, if desired (see the <a href="http://www.ijg.org/">Independent JPEG Group home page</a>)
|
||||
<p>
|
||||
If you want to use the TrueType font support, you must also
|
||||
install the <strong>Freetype library</strong>, including
|
||||
the <strong><code>freetype.h</code> header file</strong>.
|
||||
See the <a href="http://www.freetype.org/">Freetype Home Page</a>.
|
||||
No, I cannot explain why that site is down on a particular day,
|
||||
and no, I can't send you a copy.
|
||||
install the <strong>FreeType 2.x library</strong>, including
|
||||
the header files. See the <a href="http://www.freetype.org/">Freetype
|
||||
Home Page</a>, or <a href="http://freetype.sourceforge.net/">SourceForge</a>.
|
||||
No, I cannot explain why that site is down on a particular day, and no, I
|
||||
can't send you a copy.
|
||||
<p>
|
||||
If you want to use the Xpm color bitmap loading support, you must also
|
||||
have the X Window System and the Xpm library installed (Xpm is often
|
||||
|
@ -51,18 +53,7 @@ information. Thank you!
|
|||
<H3>Table of Contents</H3>
|
||||
<UL>
|
||||
<LI><A HREF="#notice">Credits and license terms</A>
|
||||
<LI><A HREF="#whatsnew1.8.3">What's new in version 1.8.3?</A>
|
||||
<LI><A HREF="#whatsnew1.8.2">What's new in version 1.8.2?</A>
|
||||
<LI><A HREF="#whatsnew1.8.1">What's new in version 1.8.1?</A>
|
||||
<LI><A HREF="#whatsnew1.8">What's new in version 1.8?</A>
|
||||
<LI><A HREF="#whatsnew1.7.3">What's new in version 1.7.3?</A>
|
||||
<LI><A HREF="#whatsnew1.7.2">What's new in version 1.7.2?</A>
|
||||
<LI><A HREF="#whatsnew1.7.1">What's new in version 1.7.1?</A>
|
||||
<LI><A HREF="#whatsnew1.7">What's new in version 1.7?</A>
|
||||
<LI><A HREF="#whatsnew1.6.3">What's new in version 1.6.3?</A>
|
||||
<LI><A HREF="#whatsnew1.6.2">What's new in version 1.6.2?</A>
|
||||
<LI><A HREF="#whatsnew1.6.1">What's new in version 1.6.1?</A>
|
||||
<LI><A HREF="#whatsnew1.6">What's new in version 1.6?</A>
|
||||
<LI><A HREF="#whatsnew1.8.4">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>
|
||||
|
@ -127,7 +118,7 @@ including but not limited to implied warranties of merchantability and
|
|||
fitness for a particular purpose, with respect to this code and accompanying
|
||||
documentation.
|
||||
<p>
|
||||
Although their code does not appear in gd 1.8.3, the authors wish to
|
||||
Although their code does not appear in gd 1.8.4, the authors wish to
|
||||
thank David Koblas, David Rowley, and Hutchison Avenue Software
|
||||
Corporation for their prior contributions.
|
||||
</blockquote>
|
||||
|
@ -175,17 +166,33 @@ Pascal enthusiasts should look into Michael Bradbury's
|
|||
A new gd interface is now available for
|
||||
<a href="http://www.numeric-quest.com/haskell/gd/index.html">Haskell
|
||||
programmers</a>.
|
||||
<h4>REXX</h4>
|
||||
A
|
||||
<a href="http://www.lightlink.com/hessling/RexxGd/index.html">gd interface
|
||||
for the REXX language</a> is available.
|
||||
<h4>Any Language</h4>
|
||||
There are, at the moment, at least three simple interpreters that
|
||||
perform gd operations. You can output the desired commands to a simple
|
||||
text file from whatever scripting language you prefer to use, then
|
||||
invoke the interpreter.
|
||||
<p>
|
||||
These packages have not been updated to gd 1.6 and up as of this writing.
|
||||
|
||||
<ul>
|
||||
<li><a href="http://s27w007.pswfs.gov/tgd/">tgd</a>, by Bradley K. Sherman
|
||||
<li><a href="http://www.unimelb.edu.au/fly/fly.html">fly</a>, by Martin Gleeson
|
||||
</ul>
|
||||
<P><A NAME="whatsnew1.8.4"><H3>What's new in version 1.8.4?</H3></A>
|
||||
<ul>
|
||||
<li>Add support for FreeType2 (John Ellson ellson@lucent.com)
|
||||
<li>Add support for finding in fonts in a builtin DEFAULT_FONTPATH,
|
||||
or in a path from the GDFONTPATH environment variable.
|
||||
<li>remove some unused symbols to reduce compiler warnings
|
||||
<li>bugfix in size comparisons in gdImageCompare
|
||||
<li>REXX now mentioned
|
||||
<li>All memory allocation functions are now wrapped within the
|
||||
library; gdFree is exported and recommended for freeing memory
|
||||
returned by the gdImage(Something)Ptr family of functions.
|
||||
</ul>
|
||||
<P><A NAME="whatsnew1.8.3"><H3>What's new in version 1.8.3?</H3></A>
|
||||
<ul>
|
||||
<li>WBMP output memory leak fixed
|
||||
|
@ -367,7 +374,7 @@ Version 1.5 featured the following changes:
|
|||
<br>gdImageGd2, gdImageCreateFromGd2 - Support for new format
|
||||
<br>gdImageCopyMerge - Merges two images (useful to highlight part of an image)
|
||||
<br>gdImageCopyMergeGray - Similar to gdImageCopyMerge, but tries to preserve source image hue.
|
||||
<br>gdImagePngPtr, gdImageJpegPtr, gdImageWBMPPtr, gdImageGdPtr, gdImageGd2Ptr - return memort blocks for each type of image.
|
||||
<br>gdImagePngPtr, gdImageJpegPtr, gdImageWBMPPtr, gdImageGdPtr, gdImageGd2Ptr - return memory blocks for each type of image.
|
||||
<br>gdImageCreateFromPngCtx, gdImageCreateFromGdCtx, gdImageCreateFromGd2Ctx, gdImageCreateFromGd2PartCtx - Support for new I/O context.
|
||||
|
||||
</dl>
|
||||
|
@ -475,13 +482,13 @@ newsgroups relevant to your particular system.
|
|||
<A NAME="getgd"><H3>How do I get gd?</H3></A>
|
||||
<h4>By HTTP</h4>
|
||||
<ul>
|
||||
<li><a href="http://www.boutell.com/gd/http/gd-1.8.3.tar.gz">Gzipped Tar File (Unix)</a>
|
||||
<li><a href="http://www.boutell.com/gd/http/gd-1.8.3.zip">.ZIP File (Windows)</a>
|
||||
<li><a href="http://www.boutell.com/gd/http/gd-1.8.4.tar.gz">Gzipped Tar File (Unix)</a>
|
||||
<li><a href="http://www.boutell.com/gd/http/gd-1.8.4.zip">.ZIP File (Windows)</a>
|
||||
</ul>
|
||||
<h4>By FTP</h4>
|
||||
<ul>
|
||||
<li><a href="ftp://ftp.boutell.com/pub/boutell/gd/gd-1.8.3.tar.gz">Gzipped Tar File (Unix)</a>
|
||||
<li><a href="ftp://ftp.boutell.com/pub/boutell/gd/gd-1.8.3.zip">.ZIP File (Windows)</a>
|
||||
<li><a href="ftp://ftp.boutell.com/pub/boutell/gd/gd-1.8.4.tar.gz">Gzipped Tar File (Unix)</a>
|
||||
<li><a href="ftp://ftp.boutell.com/pub/boutell/gd/gd-1.8.4.zip">.ZIP File (Windows)</a>
|
||||
</ul>
|
||||
<P>
|
||||
<A NAME="buildgd"><H3>How do I build gd?</H3></A>
|
||||
|
@ -492,10 +499,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-1.8.3".
|
||||
Unpacking the archive will produce a directory called "gd-1.8.4".
|
||||
<p>
|
||||
<h4>For Unix</h4>
|
||||
<code>cd</code> to the 1.8.3 directory. Edit the Makefile with
|
||||
<code>cd</code> to the 1.8.4 directory. Edit the Makefile with
|
||||
your preferred text editor and make any necessary changes to the
|
||||
settings at the top, especially if you want Xpm or TrueType support.
|
||||
Next, type "make". If you are the system administrator, and you
|
||||
|
@ -542,8 +549,8 @@ operating systems you will add gd.c to your own project.
|
|||
<P>
|
||||
If you want to use the provided fonts, include
|
||||
gdfontt.h, gdfonts.h, gdfontmb.h, gdfontl.h and/or gdfontg.h. For
|
||||
more impressive results, install libttf and use the new
|
||||
<a href="#gdImageStringTTF">gdImageStringTTF</a>
|
||||
more impressive results, install FreeType 2.x and use the new
|
||||
<a href="#gdImageStringFT">gdImageStringFT</a>
|
||||
function. If you are not using the provided Makefile and/or a
|
||||
library-based approach, be sure to include the source modules as well in your
|
||||
project. (They may be too large for 16-bit memory models,
|
||||
|
@ -1052,7 +1059,10 @@ void* gdImageJpegPtr(gdImagePtr im, int *size)</A>
|
|||
<STRONG>(FUNCTION)</STRONG>
|
||||
<DD>Identical to gdImageJpeg except that it returns a pointer to a memory
|
||||
area with the JPEG data. This memory must be freed by the caller when it is
|
||||
no longer needed. The 'size' parameter receives the total size of the block
|
||||
no longer needed. <strong>The caller must invoke gdFree(), not free(),
|
||||
unless the caller is absolutely certain that the same implementations of
|
||||
malloc, free, etc. are used both at library build time and at application
|
||||
build time.</strong> The 'size' parameter receives the total size of the block
|
||||
of memory.
|
||||
<DT><A NAME="gdImagePng">
|
||||
void gdImagePng(gdImagePtr im, FILE *out)</A>
|
||||
|
@ -1092,7 +1102,10 @@ void* gdImagePngPtr(gdImagePtr im, int *size)</A>
|
|||
<STRONG>(FUNCTION)</STRONG>
|
||||
<DD>Identical to gdImagePng except that it returns a pointer to a memory
|
||||
area with the PNG data. This memory must be freed by the caller when it is
|
||||
no longer needed. The 'size' parameter receives the total size of the block
|
||||
no longer needed. <strong>The caller must invoke gdFree(), not free(),
|
||||
unless the caller is absolutely certain that the same implementations of
|
||||
malloc, free, etc. are used both at library build time and at application
|
||||
build time.</strong> The 'size' parameter receives the total size of the block
|
||||
of memory.
|
||||
|
||||
<DT><A NAME="gdImagePngToSink">gdImagePngToSink(gdImagePtr im, gdSinkPtr out)</A>
|
||||
|
@ -1174,7 +1187,10 @@ void* gdImageWBMPPtr(gdImagePtr im, int *size)</A>
|
|||
<STRONG>(FUNCTION)</STRONG>
|
||||
<DD>Identical to gdImageWBMP except that it returns a pointer to a memory
|
||||
area with the WBMP data. This memory must be freed by the caller when it is
|
||||
no longer needed. The 'size' parameter receives the total size of the block
|
||||
no longer needed. <strong>The caller must invoke gdFree(), not free(),
|
||||
unless the caller is absolutely certain that the same implementations of
|
||||
malloc, free, etc. are used both at library build time and at application
|
||||
build time.</strong> The 'size' parameter receives the total size of the block
|
||||
of memory.
|
||||
<DT><A NAME="gdImageGd">
|
||||
void gdImageGd(gdImagePtr im, FILE *out)</A>
|
||||
|
@ -1220,7 +1236,10 @@ void* gdImageGdPtr(gdImagePtr im, int *size)</A>
|
|||
<STRONG>(FUNCTION)</STRONG>
|
||||
<DD>Identical to gdImageGd except that it returns a pointer to a memory
|
||||
area with the GD data. This memory must be freed by the caller when it is
|
||||
no longer needed. The 'size' parameter receives the total size of the block
|
||||
no longer needed. <strong>The caller must invoke gdFree(), not free(),
|
||||
unless the caller is absolutely certain that the same implementations of
|
||||
malloc, free, etc. are used both at library build time and at application
|
||||
build time.</strong> The 'size' parameter receives the total size of the block
|
||||
of memory.
|
||||
|
||||
<DT><A NAME="gdImageGd2">
|
||||
|
@ -1277,7 +1296,10 @@ void* gdImageGd2Ptr(gdImagePtr im, int chunkSize, int fmt, int *size)</A>
|
|||
<STRONG>(FUNCTION)</STRONG>
|
||||
<DD>Identical to gdImageGd2 except that it returns a pointer to a memory
|
||||
area with the GD2 data. This memory must be freed by the caller when it is
|
||||
no longer needed. The 'size' parameter receives the total size of the block
|
||||
no longer needed. <strong>The caller must invoke gdFree(), not free(),
|
||||
unless the caller is absolutely certain that the same implementations of
|
||||
malloc, free, etc. are used both at library build time and at application
|
||||
build time.</strong> The 'size' parameter receives the total size of the block
|
||||
of memory.
|
||||
|
||||
</DL>
|
||||
|
@ -1857,7 +1879,8 @@ gdImageChar is used to draw single characters on the image.
|
|||
(To draw multiple characters, use <A HREF="#gdImageString">
|
||||
gdImageString</A> or <A HREF="#gdImageString16">
|
||||
gdImageString16</A>.
|
||||
See also <A HREF="#gdImageStringTTF">gdImageStringTTF</A>, new with gd-1.6.2.)
|
||||
See also <A HREF="#gdImageStringFT">gdImageStringFT</A> for a high quality
|
||||
solution.)
|
||||
The second argument is a pointer to a font definition structure; five fonts are
|
||||
provided with gd, gdFontTiny, gdFontSmall, gdFontMediumBold,
|
||||
gdFontLarge, and gdFontGiant. You must
|
||||
|
@ -1948,7 +1971,8 @@ The null-terminated C string specified
|
|||
by the fifth argument is drawn from left to right in the specified
|
||||
color. (See <A HREF="#gdImageStringUp">gdImageStringUp</A> for a way
|
||||
of drawing vertical text.
|
||||
See also <A HREF="#gdImageStringTTF">gdImageStringTTF</A>, new with gd-1.6.2.)
|
||||
See also <A HREF="#gdImageStringFT">gdImageStringFT</A> for a high
|
||||
quality solution.)
|
||||
Pixels not set by a particular character retain their previous color.
|
||||
<PRE>
|
||||
#include "gd.h"
|
||||
|
@ -2070,20 +2094,123 @@ set by a particular character retain their previous color.
|
|||
This function was added in gd1.3 to provide a means of rendering
|
||||
fonts with more than 256 characters for those who have them. A
|
||||
more frequently used routine is <a href="#gdImageStringUp">gdImageStringUp</a>.
|
||||
<DT><A NAME="gdImageStringFT">
|
||||
char *gdImageStringFT(gdImagePtr im, int *brect,
|
||||
int fg, char *fontname, double ptsize, double angle,
|
||||
int x, int y, char *string)</A>
|
||||
<STRONG>(FUNCTION)</STRONG>
|
||||
<DD>
|
||||
<strong>RECOMMENDED. New in 1.8.4.</strong> gdImageStringFT draws text using the
|
||||
FreeType 2.x library.
|
||||
<p>
|
||||
gdImageStringFT draws a string of anti-aliased characters on the image using
|
||||
the <A HREF=http://www.freetype.org/>FreeType</A>
|
||||
library to render user-supplied TrueType fonts. <strong>We do not provide
|
||||
TrueType fonts (.ttf and .ttc files). Obtaining them is entirely up to
|
||||
you.</strong> The string is anti-aliased, meaning that there should be
|
||||
fewer "jaggies" visible. The fontname is the full pathname to a TrueType
|
||||
font file, or a font face name if the GDFONTPATH environment variable
|
||||
or FreeType's DEFAULT_FONTPATH variable have been set intelligently.
|
||||
The string may be arbitrarily scaled (ptsize) and rotated (angle in radians).
|
||||
<p>
|
||||
The user-supplied int brect[8] array is filled on return from gdImageStringFT
|
||||
with the 8 elements representing the 4 corner coordinates of the
|
||||
bounding rectangle.
|
||||
<TABLE BORDER="1">
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP" >0</TD><TD ALIGN="LEFT" VALIGN="TOP">
|
||||
lower left corner, X position</TD></TR>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP >1</TD><TD ALIGN="LEFT" VALIGN="TOP">
|
||||
lower left corner, Y position</TD></TR>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP >2</TD><TD ALIGN="LEFT" VALIGN="TOP">
|
||||
lower right corner, X position</TD></TR>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP">3</TD><TD ALIGN="LEFT" VALIGN="TOP">
|
||||
lower right corner, Y position</TD></TR>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP">4</TD><TD ALIGN="LEFT" VALIGN="TOP">
|
||||
upper right corner, X position</TD></TR>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP">5</TD><TD ALIGN="LEFT" VALIGN="TOP">
|
||||
upper right corner, Y position</TD></TR>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP">6</TD><TD ALIGN="LEFT" VALIGN="TOP">
|
||||
upper left corner, X position</TD></TR>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP">7</TD><TD ALIGN="LEFT" VALIGN="TOP">
|
||||
upper left corner, Y position</TD></TR>
|
||||
</TABLE>
|
||||
<p>
|
||||
The points are relative to the text regardless of the angle, so "upper left"
|
||||
means in the top left-hand corner seeing the text horizontally.
|
||||
<p>
|
||||
Use a NULL gdImagePtr to get the bounding rectangle without rendering.
|
||||
This is a relatively cheap operation if followed by a rendering of the same
|
||||
string, because of the caching of the partial rendering during bounding
|
||||
rectangle calculation.
|
||||
<p>
|
||||
The string is rendered in the color indicated by the gf color index.
|
||||
<strong>Use the negative of the desired color index to
|
||||
disable anti-aliasing.</strong>
|
||||
<p>
|
||||
The string may contain UTF-8 sequences like: "&#192;"
|
||||
<p>
|
||||
gdImageStringFT will return a null char* on success, or an error
|
||||
string on failure.
|
||||
<PRE>
|
||||
#include "gd.h"
|
||||
#include <string.h>
|
||||
... inside a function ...
|
||||
<A HREF="#gdImagePtr">gdImagePtr</A> im;
|
||||
int black;
|
||||
int white;
|
||||
int brect[8];
|
||||
int x, y;
|
||||
char *err;
|
||||
|
||||
char *s = "Hello."; /* String to draw. */
|
||||
double sz = 40.;
|
||||
char *f = "/usr/local/share/ttf/Times.ttf"; /* User supplied font */
|
||||
|
||||
/* obtain brect so that we can size the image */
|
||||
err = <A HREF="#gdImageStringFT">gdImageStringFT</A>(NULL,&brect[0],0,f,sz,0.,0,0,s);
|
||||
if (err) {fprintf(stderr,err); return 1;}
|
||||
|
||||
/* create an image big enough for the string plus a little whitespace */
|
||||
x = brect[2]-brect[6] + 6;
|
||||
y = brect[3]-brect[7] + 6;
|
||||
im = <A HREF="#gdImageCreate">gdImageCreate</A>(x,y);
|
||||
|
||||
/* Background color (first allocated) */
|
||||
white = <A HREF="#gdImageColorResolve">gdImageColorResolve</A>(im, 255, 255, 255);
|
||||
black = <A HREF="#gdImageColorResolve">gdImageColorResolve</A>(im, 0, 0, 0);
|
||||
|
||||
/* render the string, offset origin to center string*/
|
||||
/* note that we use top-left coordinate for adjustment
|
||||
* since gd origin is in top-left with y increasing downwards. */
|
||||
x = 3 - brect[6];
|
||||
y = 3 - brect[7];
|
||||
err = <A HREF="#gdImageStringFT">gdImageStringFT</A>(im,&brect[0],black,f,sz,0.0,x,y,s);
|
||||
if (err) {fprintf(stderr,err); return 1;}
|
||||
|
||||
/* Write img to stdout */
|
||||
<A HREF="#gdImagePng">gdImagePng</A>(im, stdout);
|
||||
|
||||
/* Destroy it */
|
||||
<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
|
||||
</PRE>
|
||||
<DT><A NAME="gdImageStringTTF">
|
||||
char *gdImageStringTTF(gdImagePtr im, int *brect,
|
||||
int fg, char *fontname, double ptsize, double angle,
|
||||
int x, int y, char *string)</A>
|
||||
<STRONG>(FUNCTION)</STRONG>
|
||||
<DD>
|
||||
gdImageStringTTF is draws a string of anti-aliased characters on the image
|
||||
using the
|
||||
<A HREF=http://www.freetype.org/>FreeType</A>
|
||||
library to print from user-supplied TrueType fonts.
|
||||
<strong>We do not provide TrueType fonts. Obtaining them
|
||||
is entirely up to you.</strong>
|
||||
The string is anti-aliased, meaning that there should be less "jaggies."
|
||||
The fontname is the full pathname to a TrueType font file.
|
||||
<strong>DEPRECATED.</strong> gdImageStringTTF draws text using the
|
||||
FreeType 1.x library. For better results, use
|
||||
<a href="#gdImageStringFT">gdImageStringFT</a> and FreeType 2.x.
|
||||
<p>
|
||||
gdImageStringTTF draws a string of anti-aliased characters on the image using
|
||||
the <A HREF=http://www.freetype.org/>FreeType</A>
|
||||
library to render user-supplied TrueType fonts. <strong>We do not provide
|
||||
TrueType fonts (.ttf and .ttc files). Obtaining them is entirely up to
|
||||
you.</strong> The string is anti-aliased, meaning that there should be
|
||||
fewer "jaggies" visible. The fontname is the full pathname to a TrueType
|
||||
font file, or a font face name if the GDFONTPATH environment variable
|
||||
or FreeType's DEFAULT_FONTPATH variable have been set intelligently.
|
||||
The string may be arbitrarily scaled (ptsize) and rotated (angle in radians).
|
||||
<p>
|
||||
The user-supplied int brect[8] array is filled on return from gdImageStringTTF
|
||||
|
@ -2117,7 +2244,8 @@ string, because of the caching of the partial rendering during bounding
|
|||
rectangle calculation.
|
||||
<p>
|
||||
The string is rendered in the color indicated by the gf color index.
|
||||
Use the negative of the desired color index to disable anti-aliasing.
|
||||
<strong>Use the negative of the desired color index to
|
||||
disable anti-aliasing.</strong>
|
||||
<p>
|
||||
The string may contain UTF-8 sequences like: "&#192;"
|
||||
<p>
|
||||
|
@ -2165,6 +2293,7 @@ if (err) {fprintf(stderr,err); return 1;}
|
|||
/* Destroy it */
|
||||
<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
|
||||
</PRE>
|
||||
|
||||
</DL>
|
||||
<H3><A NAME="colors">Color-handling functions</A></H3>
|
||||
<DL>
|
||||
|
@ -2718,6 +2847,14 @@ out = fopen("test.png", "wb");
|
|||
fclose(out);
|
||||
<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
|
||||
</PRE>
|
||||
<DT><A NAME="gdFree">gdFree(void *ptr)</A> <strong>(FUNCTION)</strong>
|
||||
<DD>
|
||||
gdFree provides a reliable way to free memory allocated by functions
|
||||
such as <a href="#gdImagePngPtr">gdImagePngPtr</a> which return
|
||||
blocks of memory. Use of this function guarantees that the
|
||||
version of <code>free()</code> that is ultimately called will
|
||||
be intended for use with the version of <code>malloc()</code> that
|
||||
originally allocated the block.
|
||||
</DL>
|
||||
<H3><A NAME="constants">Constants</A></H3>
|
||||
<DL>
|
||||
|
@ -2906,6 +3043,7 @@ Be sure to read this manual carefully first.
|
|||
<A HREF="#gdDashSize">gdDashSize</A> |
|
||||
<A HREF="#gdFont">gdFont</A> |
|
||||
<A HREF="#gdFontPtr">gdFontPtr</A> |
|
||||
<A HREF="#gdFree">gdFree</A> |
|
||||
<A HREF="#gdImage">gdImage</A> |
|
||||
<A HREF="#gdImageArc">gdImageArc</A> |
|
||||
<A HREF="#gdImageBlue">gdImageBlue</A> |
|
||||
|
@ -2958,6 +3096,7 @@ Be sure to read this manual carefully first.
|
|||
<A HREF="#gdImageSetTile">gdImageSetTile</A> |
|
||||
<A HREF="#gdImageString">gdImageString</A> |
|
||||
<A HREF="#gdImageString16">gdImageString16</A> |
|
||||
<A HREF="#gdImageStringFT">gdImageStringFT</A> |
|
||||
<A HREF="#gdImageStringTTF">gdImageStringTTF</A> |
|
||||
<A HREF="#gdImageStringUp">gdImageStringUp</A> |
|
||||
<A HREF="#gdImageStringUp">gdImageStringUp16</A> |
|
||||
|
|
263
src/readme.txt
263
src/readme.txt
|
@ -1,11 +1,11 @@
|
|||
|
||||
gd 1.8.3
|
||||
gd 1.8.4
|
||||
|
||||
A graphics library for fast image creation
|
||||
|
||||
Follow this link to the latest version of this document.
|
||||
|
||||
_HEY! READ THIS!_ gd 1.8.3 creates PNG, JPEG and WBMP images, not
|
||||
_HEY! READ THIS!_ gd 1.8.4 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 well with photographic
|
||||
images, and is still more compatible with the major Web browsers
|
||||
|
@ -18,18 +18,19 @@ Follow this link to the latest version of this document.
|
|||
well-compressed, modern image formats such as PNG and JPEG as soon
|
||||
as possible.
|
||||
|
||||
gd 1.8.3 _requires_ that the following libraries also be installed:
|
||||
gd 1.8.4 _requires_ that the following libraries also be installed:
|
||||
|
||||
libpng
|
||||
libpng (see the libpng home page)
|
||||
|
||||
jpeg-6b or later
|
||||
zlib (see the info-zip home page) zlib
|
||||
|
||||
zlib
|
||||
jpeg-6b or later, if desired (see the Independent JPEG Group home
|
||||
page)
|
||||
|
||||
If you want to use the TrueType font support, you must also install
|
||||
the _Freetype library_, including the _freetype.h header file_. See
|
||||
the Freetype Home Page. No, I cannot explain why that site is down
|
||||
on a particular day, and no, I can't send you a copy.
|
||||
the _FreeType 2.x library_, including the header files. See the
|
||||
Freetype Home Page, or SourceForge. No, I cannot explain why that
|
||||
site is down on a particular day, and no, I can't send you a copy.
|
||||
|
||||
If you want to use the Xpm color bitmap loading support, you must
|
||||
also have the X Window System and the Xpm library installed (Xpm is
|
||||
|
@ -42,18 +43,7 @@ Follow this link to the latest version of this document.
|
|||
Table of Contents
|
||||
|
||||
* Credits and license terms
|
||||
* What's new in version 1.8.3?
|
||||
* What's new in version 1.8.2?
|
||||
* What's new in version 1.8.1?
|
||||
* What's new in version 1.8?
|
||||
* What's new in version 1.7.3?
|
||||
* What's new in version 1.7.2?
|
||||
* What's new in version 1.7.1?
|
||||
* What's new in version 1.7?
|
||||
* What's new in version 1.6.3?
|
||||
* What's new in version 1.6.2?
|
||||
* What's new in version 1.6.1?
|
||||
* What's new in version 1.6?
|
||||
* What's new in version "XYZ" of GD?
|
||||
* What is gd?
|
||||
* What if I want to use another programming language?
|
||||
* What else do I need to use gd?
|
||||
|
@ -117,7 +107,7 @@ COPYRIGHT STATEMENT FOLLOWS THIS LINE
|
|||
particular purpose, with respect to this code and accompanying
|
||||
documentation.
|
||||
|
||||
Although their code does not appear in gd 1.8.3, the authors wish
|
||||
Although their code does not appear in gd 1.8.4, the authors wish
|
||||
to thank David Koblas, David Rowley, and Hutchison Avenue Software
|
||||
Corporation for their prior contributions.
|
||||
|
||||
|
@ -164,6 +154,10 @@ END OF COPYRIGHT STATEMENT
|
|||
|
||||
A new gd interface is now available for Haskell programmers.
|
||||
|
||||
REXX
|
||||
|
||||
A gd interface for the REXX language is available.
|
||||
|
||||
Any Language
|
||||
|
||||
There are, at the moment, at least three simple interpreters that
|
||||
|
@ -171,11 +165,21 @@ END OF COPYRIGHT STATEMENT
|
|||
text file from whatever scripting language you prefer to use, then
|
||||
invoke the interpreter.
|
||||
|
||||
These packages have not been updated to gd 1.6 and up as of this
|
||||
writing.
|
||||
* tgd, by Bradley K. Sherman
|
||||
* fly, by Martin Gleeson
|
||||
|
||||
What's new in version 1.8.4?
|
||||
|
||||
* Add support for FreeType2 (John Ellson ellson@lucent.com)
|
||||
* Add support for finding in fonts in a builtin DEFAULT_FONTPATH, or
|
||||
in a path from the GDFONTPATH environment variable.
|
||||
* remove some unused symbols to reduce compiler warnings
|
||||
* bugfix in size comparisons in gdImageCompare
|
||||
* REXX now mentioned
|
||||
* All memory allocation functions are now wrapped within the
|
||||
library; gdFree is exported and recommended for freeing memory
|
||||
returned by the gdImage(Something)Ptr family of functions.
|
||||
|
||||
What's new in version 1.8.3?
|
||||
|
||||
* WBMP output memory leak fixed
|
||||
|
@ -369,7 +373,7 @@ END OF COPYRIGHT STATEMENT
|
|||
gdImageCopyMergeGray - Similar to gdImageCopyMerge, but tries
|
||||
to preserve source image hue.
|
||||
gdImagePngPtr, gdImageJpegPtr, gdImageWBMPPtr, gdImageGdPtr,
|
||||
gdImageGd2Ptr - return memort blocks for each type of image.
|
||||
gdImageGd2Ptr - return memory blocks for each type of image.
|
||||
gdImageCreateFromPngCtx, gdImageCreateFromGdCtx,
|
||||
gdImageCreateFromGd2Ctx, gdImageCreateFromGd2PartCtx - Support
|
||||
for new I/O context.
|
||||
|
@ -493,11 +497,11 @@ END OF COPYRIGHT STATEMENT
|
|||
(Windows), please consult with an experienced user of your system.
|
||||
Sorry, we cannot answer questions about basic Internet skills.
|
||||
|
||||
Unpacking the archive will produce a directory called "gd-1.8.3".
|
||||
Unpacking the archive will produce a directory called "gd-1.8.4".
|
||||
|
||||
For Unix
|
||||
|
||||
cd to the 1.8.3 directory. Edit the Makefile with your preferred text
|
||||
cd to the 1.8.4 directory. Edit the Makefile with your preferred text
|
||||
editor and make any necessary changes to the settings at the top,
|
||||
especially if you want Xpm or TrueType support. Next, type "make". If
|
||||
you are the system administrator, and you wish to make the gd library
|
||||
|
@ -544,10 +548,10 @@ END OF COPYRIGHT STATEMENT
|
|||
|
||||
If you want to use the provided fonts, include gdfontt.h, gdfonts.h,
|
||||
gdfontmb.h, gdfontl.h and/or gdfontg.h. For more impressive results,
|
||||
install libttf and use the new gdImageStringTTF function. If you are
|
||||
not using the provided Makefile and/or a library-based approach, be
|
||||
sure to include the source modules as well in your project. (They may
|
||||
be too large for 16-bit memory models, that is, 16-bit DOS and
|
||||
install FreeType 2.x and use the new gdImageStringFT function. If you
|
||||
are not using the provided Makefile and/or a library-based approach,
|
||||
be sure to include the source modules as well in your project. (They
|
||||
may be too large for 16-bit memory models, that is, 16-bit DOS and
|
||||
Windows.)
|
||||
|
||||
Here is a short example program. _(For a more advanced example, see
|
||||
|
@ -1015,7 +1019,10 @@ gdImageDestroy(im);
|
|||
void* gdImageJpegPtr(gdImagePtr im, int *size) _(FUNCTION)_
|
||||
Identical to gdImageJpeg except that it returns a pointer to a memory
|
||||
area with the JPEG data. This memory must be freed by the caller when
|
||||
it is no longer needed. The 'size' parameter receives the total size
|
||||
it is no longer needed. _The caller must invoke gdFree(), not free(),
|
||||
unless the caller is absolutely certain that the same implementations
|
||||
of malloc, free, etc. are used both at library build time and at
|
||||
application build time._ The 'size' parameter receives the total size
|
||||
of the block of memory.
|
||||
|
||||
void gdImagePng(gdImagePtr im, FILE *out) _(FUNCTION)_
|
||||
|
@ -1050,7 +1057,10 @@ gdImageDestroy(im);
|
|||
void* gdImagePngPtr(gdImagePtr im, int *size) _(FUNCTION)_
|
||||
Identical to gdImagePng except that it returns a pointer to a memory
|
||||
area with the PNG data. This memory must be freed by the caller when
|
||||
it is no longer needed. The 'size' parameter receives the total size
|
||||
it is no longer needed. _The caller must invoke gdFree(), not free(),
|
||||
unless the caller is absolutely certain that the same implementations
|
||||
of malloc, free, etc. are used both at library build time and at
|
||||
application build time._ The 'size' parameter receives the total size
|
||||
of the block of memory.
|
||||
|
||||
gdImagePngToSink(gdImagePtr im, gdSinkPtr out) _(FUNCTION)_
|
||||
|
@ -1121,7 +1131,10 @@ gdImageDestroy(im);
|
|||
void* gdImageWBMPPtr(gdImagePtr im, int *size) _(FUNCTION)_
|
||||
Identical to gdImageWBMP except that it returns a pointer to a memory
|
||||
area with the WBMP data. This memory must be freed by the caller when
|
||||
it is no longer needed. The 'size' parameter receives the total size
|
||||
it is no longer needed. _The caller must invoke gdFree(), not free(),
|
||||
unless the caller is absolutely certain that the same implementations
|
||||
of malloc, free, etc. are used both at library build time and at
|
||||
application build time._ The 'size' parameter receives the total size
|
||||
of the block of memory.
|
||||
|
||||
void gdImageGd(gdImagePtr im, FILE *out) _(FUNCTION)_
|
||||
|
@ -1160,8 +1173,11 @@ gdImageDestroy(im);
|
|||
void* gdImageGdPtr(gdImagePtr im, int *size) _(FUNCTION)_
|
||||
Identical to gdImageGd except that it returns a pointer to a memory
|
||||
area with the GD data. This memory must be freed by the caller when it
|
||||
is no longer needed. The 'size' parameter receives the total size of
|
||||
the block of memory.
|
||||
is no longer needed. _The caller must invoke gdFree(), not free(),
|
||||
unless the caller is absolutely certain that the same implementations
|
||||
of malloc, free, etc. are used both at library build time and at
|
||||
application build time._ The 'size' parameter receives the total size
|
||||
of the block of memory.
|
||||
|
||||
void gdImageGd2(gdImagePtr im, FILE *out, int chunkSize, int fmt)
|
||||
_(FUNCTION)_
|
||||
|
@ -1209,7 +1225,10 @@ gdImageDestroy(im);
|
|||
_(FUNCTION)_
|
||||
Identical to gdImageGd2 except that it returns a pointer to a memory
|
||||
area with the GD2 data. This memory must be freed by the caller when
|
||||
it is no longer needed. The 'size' parameter receives the total size
|
||||
it is no longer needed. _The caller must invoke gdFree(), not free(),
|
||||
unless the caller is absolutely certain that the same implementations
|
||||
of malloc, free, etc. are used both at library build time and at
|
||||
application build time._ The 'size' parameter receives the total size
|
||||
of the block of memory.
|
||||
|
||||
Drawing Functions
|
||||
|
@ -1754,19 +1773,19 @@ gdImageDestroy(im);
|
|||
c, int color) _(FUNCTION)_
|
||||
gdImageChar is used to draw single characters on the
|
||||
image. (To draw multiple characters, use gdImageString or
|
||||
gdImageString16. See also gdImageStringTTF, new with
|
||||
gd-1.6.2.) The second argument is a pointer to a font
|
||||
definition structure; five fonts are provided with gd,
|
||||
gdFontTiny, gdFontSmall, gdFontMediumBold, gdFontLarge,
|
||||
and gdFontGiant. You must include the files "gdfontt.h",
|
||||
"gdfonts.h", "gdfontmb.h", "gdfontl.h" and "gdfontg.h"
|
||||
respectively and (if you are not using a library-based
|
||||
approach) link with the corresponding .c files to use the
|
||||
provided fonts. The character specified by the fifth
|
||||
argument is drawn from left to right in the specified
|
||||
color. (See gdImageCharUp for a way of drawing vertical
|
||||
text.) Pixels not set by a particular character retain
|
||||
their previous color.
|
||||
gdImageString16. See also gdImageStringFT for a high
|
||||
quality solution.) The second argument is a pointer to a
|
||||
font definition structure; five fonts are provided with
|
||||
gd, gdFontTiny, gdFontSmall, gdFontMediumBold,
|
||||
gdFontLarge, and gdFontGiant. You must include the files
|
||||
"gdfontt.h", "gdfonts.h", "gdfontmb.h", "gdfontl.h" and
|
||||
"gdfontg.h" respectively and (if you are not using a
|
||||
library-based approach) link with the corresponding .c
|
||||
files to use the provided fonts. The character specified
|
||||
by the fifth argument is drawn from left to right in the
|
||||
specified color. (See gdImageCharUp for a way of drawing
|
||||
vertical text.) Pixels not set by a particular character
|
||||
retain their previous color.
|
||||
|
||||
|
||||
#include "gd.h"
|
||||
|
@ -1837,9 +1856,9 @@ gdImageDestroy(im);
|
|||
provided fonts. The null-terminated C string specified by
|
||||
the fifth argument is drawn from left to right in the
|
||||
specified color. (See gdImageStringUp for a way of
|
||||
drawing vertical text. See also gdImageStringTTF, new
|
||||
with gd-1.6.2.) Pixels not set by a particular character
|
||||
retain their previous color.
|
||||
drawing vertical text. See also gdImageStringFT for a
|
||||
high quality solution.) Pixels not set by a particular
|
||||
character retain their previous color.
|
||||
|
||||
|
||||
#include "gd.h"
|
||||
|
@ -1954,18 +1973,115 @@ gdImageDestroy(im);
|
|||
who have them. A more frequently used routine is
|
||||
gdImageStringUp.
|
||||
|
||||
char *gdImageStringFT(gdImagePtr im, int *brect, int fg, char
|
||||
*fontname, double ptsize, double angle, int x, int y,
|
||||
char *string) _(FUNCTION)_
|
||||
_RECOMMENDED. New in 1.8.4._ gdImageStringFT draws text
|
||||
using the FreeType 2.x library.
|
||||
|
||||
gdImageStringFT draws a string of anti-aliased characters
|
||||
on the image using the FreeType library to render
|
||||
user-supplied TrueType fonts. _We do not provide TrueType
|
||||
fonts (.ttf and .ttc files). Obtaining them is entirely
|
||||
up to you._ The string is anti-aliased, meaning that
|
||||
there should be fewer "jaggies" visible. The fontname is
|
||||
the full pathname to a TrueType font file, or a font face
|
||||
name if the GDFONTPATH environment variable or FreeType's
|
||||
DEFAULT_FONTPATH variable have been set intelligently.
|
||||
The string may be arbitrarily scaled (ptsize) and rotated
|
||||
(angle in radians).
|
||||
|
||||
The user-supplied int brect[8] array is filled on return
|
||||
from gdImageStringFT with the 8 elements representing the
|
||||
4 corner coordinates of the bounding rectangle.
|
||||
0 lower left corner, X position
|
||||
lower left corner, Y position
|
||||
lower right corner, X position
|
||||
3 lower right corner, Y position
|
||||
4 upper right corner, X position
|
||||
5 upper right corner, Y position
|
||||
6 upper left corner, X position
|
||||
7 upper left corner, Y position
|
||||
|
||||
The points are relative to the text regardless of the
|
||||
angle, so "upper left" means in the top left-hand corner
|
||||
seeing the text horizontally.
|
||||
|
||||
Use a NULL gdImagePtr to get the bounding rectangle
|
||||
without rendering. This is a relatively cheap operation
|
||||
if followed by a rendering of the same string, because of
|
||||
the caching of the partial rendering during bounding
|
||||
rectangle calculation.
|
||||
|
||||
The string is rendered in the color indicated by the gf
|
||||
color index. _Use the negative of the desired color index
|
||||
to disable anti-aliasing._
|
||||
|
||||
The string may contain UTF-8 sequences like: "À"
|
||||
|
||||
gdImageStringFT will return a null char* on success, or
|
||||
an error string on failure.
|
||||
|
||||
|
||||
#include "gd.h"
|
||||
#include <string.h>
|
||||
... inside a function ...
|
||||
gdImagePtr im;
|
||||
int black;
|
||||
int white;
|
||||
int brect[8];
|
||||
int x, y;
|
||||
char *err;
|
||||
|
||||
char *s = "Hello."; /* String to draw. */
|
||||
double sz = 40.;
|
||||
char *f = "/usr/local/share/ttf/Times.ttf"; /* User supplied font */
|
||||
|
||||
/* obtain brect so that we can size the image */
|
||||
err = gdImageStringFT(NULL,&brect[0],0,f,sz,0.,0,0,s);
|
||||
if (err) {fprintf(stderr,err); return 1;}
|
||||
|
||||
/* create an image big enough for the string plus a little whitespace */
|
||||
x = brect[2]-brect[6] + 6;
|
||||
y = brect[3]-brect[7] + 6;
|
||||
im = gdImageCreate(x,y);
|
||||
|
||||
/* Background color (first allocated) */
|
||||
white = gdImageColorResolve(im, 255, 255, 255);
|
||||
black = gdImageColorResolve(im, 0, 0, 0);
|
||||
|
||||
/* render the string, offset origin to center string*/
|
||||
/* note that we use top-left coordinate for adjustment
|
||||
* since gd origin is in top-left with y increasing downwards. */
|
||||
x = 3 - brect[6];
|
||||
y = 3 - brect[7];
|
||||
err = gdImageStringFT(im,&brect[0],black,f,sz,0.0,x,y,s);
|
||||
if (err) {fprintf(stderr,err); return 1;}
|
||||
|
||||
/* Write img to stdout */
|
||||
gdImagePng(im, stdout);
|
||||
|
||||
/* Destroy it */
|
||||
gdImageDestroy(im);
|
||||
|
||||
char *gdImageStringTTF(gdImagePtr im, int *brect, int fg, char
|
||||
*fontname, double ptsize, double angle, int x, int y,
|
||||
char *string) _(FUNCTION)_
|
||||
gdImageStringTTF is draws a string of anti-aliased
|
||||
_DEPRECATED._ gdImageStringTTF draws text using the
|
||||
FreeType 1.x library. For better results, use
|
||||
gdImageStringFT and FreeType 2.x.
|
||||
|
||||
gdImageStringTTF draws a string of anti-aliased
|
||||
characters on the image using the FreeType library to
|
||||
print from user-supplied TrueType fonts. _We do not
|
||||
provide TrueType fonts. Obtaining them is entirely up to
|
||||
you._ The string is anti-aliased, meaning that there
|
||||
should be less "jaggies." The fontname is the full
|
||||
pathname to a TrueType font file. The string may be
|
||||
arbitrarily scaled (ptsize) and rotated (angle in
|
||||
radians).
|
||||
render user-supplied TrueType fonts. _We do not provide
|
||||
TrueType fonts (.ttf and .ttc files). Obtaining them is
|
||||
entirely up to you._ The string is anti-aliased, meaning
|
||||
that there should be fewer "jaggies" visible. The
|
||||
fontname is the full pathname to a TrueType font file, or
|
||||
a font face name if the GDFONTPATH environment variable
|
||||
or FreeType's DEFAULT_FONTPATH variable have been set
|
||||
intelligently. The string may be arbitrarily scaled
|
||||
(ptsize) and rotated (angle in radians).
|
||||
|
||||
The user-supplied int brect[8] array is filled on return
|
||||
from gdImageStringTTF with the 8 elements representing
|
||||
|
@ -1990,8 +2106,8 @@ gdImageDestroy(im);
|
|||
rectangle calculation.
|
||||
|
||||
The string is rendered in the color indicated by the gf
|
||||
color index. Use the negative of the desired color index
|
||||
to disable anti-aliasing.
|
||||
color index. _Use the negative of the desired color index
|
||||
to disable anti-aliasing._
|
||||
|
||||
The string may contain UTF-8 sequences like: "À"
|
||||
|
||||
|
@ -2577,6 +2693,15 @@ gdImagePng(im, out);
|
|||
fclose(out);
|
||||
gdImageDestroy(im);
|
||||
|
||||
gdFree(void *ptr) _(FUNCTION)_
|
||||
gdFree provides a reliable way to free memory
|
||||
allocated by functions such as gdImagePngPtr which
|
||||
return blocks of memory. Use of this function
|
||||
guarantees that the version of free() that is
|
||||
ultimately called will be intended for use with the
|
||||
version of malloc() that originally allocated the
|
||||
block.
|
||||
|
||||
Constants
|
||||
|
||||
gdBrushed _(CONSTANT)_
|
||||
|
@ -2780,7 +2905,7 @@ typedef struct gdIOCtx {
|
|||
Alphabetical quick index
|
||||
|
||||
gdBrushed | gdDashSize | gdFont | gdFontPtr |
|
||||
gdImage | gdImageArc | gdImageBlue |
|
||||
gdFree | gdImage | gdImageArc | gdImageBlue |
|
||||
gdImageBoundsSafe | gdImageChar |
|
||||
gdImageCharUp | gdImageColorAllocate |
|
||||
gdImageColorClosest | gdImageColorDeallocate
|
||||
|
@ -2805,10 +2930,10 @@ typedef struct gdIOCtx {
|
|||
gdImageRed | gdImageSetBrush |
|
||||
gdImageSetPixel | gdImageSetStyle |
|
||||
gdImageSetTile | gdImageString |
|
||||
gdImageString16 | gdImageStringTTF |
|
||||
gdImageStringUp | gdImageStringUp16 |
|
||||
gdImageWBMP | gdMaxColors | gdPoint |
|
||||
gdStyled | gdStyledBrushed | gdTiled |
|
||||
gdTransparent
|
||||
gdImageString16 | gdImageStringFT |
|
||||
gdImageStringTTF | gdImageStringUp |
|
||||
gdImageStringUp16 | gdImageWBMP | gdMaxColors
|
||||
| gdPoint | gdStyled | gdStyledBrushed |
|
||||
gdTiled | gdTransparent
|
||||
|
||||
_Boutell.Com, Inc._
|
||||
|
|
42
src/wbmp.c
42
src/wbmp.c
|
@ -15,11 +15,15 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "wbmp.h"
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
|
||||
//#define __TEST /* Compile with main function */
|
||||
//#define __DEBUG /* Extra verbose when with __TEST */
|
||||
//#define __WRITE /* readwbmp and writewbmp(stdout) */
|
||||
//#define __VIEW /* view the wbmp on stdout */
|
||||
#ifdef NOTDEF
|
||||
#define __TEST /* Compile with main function */
|
||||
#define __DEBUG /* Extra verbose when with __TEST */
|
||||
#define __WRITE /* readwbmp and writewbmp(stdout) */
|
||||
#define __VIEW /* view the wbmp on stdout */
|
||||
#endif
|
||||
|
||||
/* getmbi
|
||||
** ------
|
||||
|
@ -52,7 +56,7 @@ int getmbi ( int (*getin)(void *in), void *in )
|
|||
** mbi integers it spits out.
|
||||
**
|
||||
*/
|
||||
int putmbi ( int i, int (*putout)(int c, void *out), void *out )
|
||||
void putmbi ( int i, void (*putout)(int c, void *out), void *out )
|
||||
{
|
||||
int cnt, l, accu;
|
||||
|
||||
|
@ -101,12 +105,12 @@ Wbmp *createwbmp(int width, int height, int color)
|
|||
int i;
|
||||
|
||||
Wbmp *wbmp;
|
||||
if ( (wbmp = (Wbmp *) malloc( sizeof(Wbmp) )) == NULL)
|
||||
if ( (wbmp = (Wbmp *) gdMalloc( sizeof(Wbmp) )) == NULL)
|
||||
return (NULL);
|
||||
|
||||
if ( (wbmp->bitmap = (int *) malloc( sizeof(int)*width*height )) == NULL)
|
||||
if ( (wbmp->bitmap = (int *) gdMalloc( sizeof(int)*width*height )) == NULL)
|
||||
{
|
||||
free( wbmp );
|
||||
gdFree( wbmp );
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -131,13 +135,13 @@ int readwbmp ( int (*getin)(void *in), void *in, Wbmp **return_wbmp )
|
|||
int row, col, byte, pel, pos;
|
||||
Wbmp *wbmp;
|
||||
|
||||
if ( (wbmp = (Wbmp *) malloc( sizeof(Wbmp) )) == NULL)
|
||||
if ( (wbmp = (Wbmp *) gdMalloc( sizeof(Wbmp) )) == NULL)
|
||||
return (-1);
|
||||
|
||||
wbmp->type = getin( in );
|
||||
if ( wbmp->type != 0 )
|
||||
{
|
||||
free( wbmp );
|
||||
gdFree( wbmp );
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
@ -148,14 +152,14 @@ int readwbmp ( int (*getin)(void *in), void *in, Wbmp **return_wbmp )
|
|||
wbmp->width = getmbi ( getin, in );
|
||||
if ( wbmp->width == -1 )
|
||||
{
|
||||
free( wbmp );
|
||||
gdFree( wbmp );
|
||||
return (-1);
|
||||
}
|
||||
|
||||
wbmp->height = getmbi ( getin, in );
|
||||
if ( wbmp->height == -1 )
|
||||
{
|
||||
free( wbmp );
|
||||
gdFree( wbmp );
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
@ -163,9 +167,9 @@ int readwbmp ( int (*getin)(void *in), void *in, Wbmp **return_wbmp )
|
|||
printf("W: %d, H: %d\n", wbmp->width, wbmp->height);
|
||||
#endif
|
||||
|
||||
if ( (wbmp->bitmap = (int *) malloc( sizeof(int)*wbmp->width*wbmp->height )) == NULL)
|
||||
if ( (wbmp->bitmap = (int *) gdMalloc( sizeof(int)*wbmp->width*wbmp->height )) == NULL)
|
||||
{
|
||||
free( wbmp );
|
||||
gdFree( wbmp );
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
@ -215,7 +219,7 @@ int readwbmp ( int (*getin)(void *in), void *in, Wbmp **return_wbmp )
|
|||
** a logic(?) decision ...
|
||||
**
|
||||
*/
|
||||
int writewbmp( Wbmp *wbmp, int (*putout)(int c, void *out), void *out )
|
||||
int writewbmp( Wbmp *wbmp, void (*putout)(int c, void *out), void *out )
|
||||
{
|
||||
int row, col;
|
||||
int bitpos, octet;
|
||||
|
@ -257,13 +261,13 @@ int writewbmp( Wbmp *wbmp, int (*putout)(int c, void *out), void *out )
|
|||
|
||||
/* freewbmp
|
||||
** --------
|
||||
** frees up memory occupied by a WBMP structure
|
||||
** gdFrees up memory occupied by a WBMP structure
|
||||
**
|
||||
*/
|
||||
void freewbmp( Wbmp *wbmp )
|
||||
{
|
||||
free( wbmp->bitmap );
|
||||
free( wbmp );
|
||||
gdFree( wbmp->bitmap );
|
||||
gdFree( wbmp );
|
||||
}
|
||||
|
||||
|
||||
|
@ -320,7 +324,7 @@ int main ( int argc, char *argv[] )
|
|||
FILE *wbmp_file;
|
||||
Wbmp *wbmp;
|
||||
|
||||
wbmp_file = fopen(argv[1], "r");
|
||||
wbmp_file = fopen(argv[1], "rb");
|
||||
if ( wbmp_file )
|
||||
{
|
||||
readwbmp( &getin, wbmp_file, &wbmp );
|
||||
|
|
|
@ -35,12 +35,12 @@ typedef struct Wbmp_
|
|||
** -------
|
||||
**
|
||||
*/
|
||||
int putmbi( int i, int (*putout)(int c, void *out), void *out);
|
||||
void putmbi( int i, void (*putout)(int c, void *out), void *out);
|
||||
int getmbi ( int (*getin)(void *in), void *in );
|
||||
int skipheader( int (*getin)(void *in), void *in );
|
||||
Wbmp *createwbmp( int width, int height, int color );
|
||||
int readwbmp( int (*getin)(void *in), void *in, Wbmp **wbmp );
|
||||
int writewbmp( Wbmp *wbmp, int (*putout)( int c, void *out), void *out);
|
||||
int writewbmp( Wbmp *wbmp, void (*putout)( int c, void *out), void *out);
|
||||
void freewbmp( Wbmp *wbmp );
|
||||
void printwbmp( Wbmp *wbmp );
|
||||
|
||||
|
|
Loading…
Reference in New Issue