static int gdAlphaOverlayColor(int src, int dst, int max);
int gdImageGetTrueColorPixel(gdImagePtr im, int x, int y);
-void php_gd_error_ex(int type, const char *format, ...)
+void php_gd_error_ex(int type, const char *format, ...)
{
va_list args;
-
+
TSRMLS_FETCH();
-
+
va_start(args, format);
php_verror(NULL, "", type, format, args TSRMLS_CC);
va_end(args);
void php_gd_error(const char *format, ...)
{
va_list args;
-
+
TSRMLS_FETCH();
-
+
va_start(args, format);
php_verror(NULL, "", E_WARNING, format, args TSRMLS_CC);
va_end(args);
}
/* This code is taken from http://www.acm.org/jgt/papers/SmithLyons96/hwb_rgb.html, an article
- * on colour conversion to/from RBG and HWB colour systems.
- * It has been modified to return the converted value as a * parameter.
+ * on colour conversion to/from RBG and HWB colour systems.
+ * It has been modified to return the converted value as a * parameter.
*/
#define RETURN_HWB(h, w, b) {HWB->H = h; HWB->W = w; HWB->B = b; return HWB;}
/*
- * Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms. Pure
- * red always maps to 6 in this implementation. Therefore UNDEFINED can be
+ * Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms. Pure
+ * red always maps to 6 in this implementation. Therefore UNDEFINED can be
* defined as 0 in situations where only unsigned numbers are desired.
*/
typedef struct
static HWBType * RGB_to_HWB (RGBType RGB, HWBType * HWB)
{
/*
- * RGB are each on [0, 1]. W and B are returned on [0, 1] and H is
- * returned on [0, 6]. Exception: H is returned UNDEFINED if W == 1 - B.
+ * RGB are each on [0, 1]. W and B are returned on [0, 1] and H is
+ * returned on [0, 6]. Exception: H is returned UNDEFINED if W == 1 - B.
*/
float R = RGB.R, G = RGB.G, B = RGB.B, w, v, b, f;
}
f = (R == w) ? G - B : ((G == w) ? B - R : R - G);
i = (R == w) ? 3 : ((G == w) ? 5 : 1);
-
+
RETURN_HWB(i - f / (v - w), w, b);
}
*/
static RGBType * HWB_to_RGB (HWBType HWB, RGBType * RGB)
{
- /*
- * H is given on [0, 6] or UNDEFINED. W and B are given on [0, 1].
- * RGB are each returned on [0, 1].
+ /*
+ * H is given on [0, 6] or UNDEFINED. W and B are given on [0, 1].
+ * RGB are each returned on [0, 1].
*/
float h = HWB.H, w = HWB.W, b = HWB.B, v, n, f;
im->blue[ct] = b;
im->alpha[ct] = a;
im->open[ct] = 0;
-
+
return ct;
}
* Given the end points of a line, and a bounding rectangle (which we
* know to be from (0,0) to (SX,SY)), adjust the endpoints to be on
* the edges of the rectangle if the line should be drawn at all,
- * otherwise return a failure code
+ * otherwise return a failure code
*/
/* this does "one-dimensional" clipping: note that the second time it
* - the comments ignore this (if you can understand it when it's
* looking at the X parameters, it should become clear what happens on
* the second call!) The code is simplified from that in the article,
- * as we know that gd images always start at (0,0)
+ * as we know that gd images always start at (0,0)
*/
static int clip_1d(int *x0, int *y0, int *x1, int *y1, int maxdim) {
}
m = (*y1 - *y0)/(double)(*x1 - *x0); /* calculate the slope of the line */
*y0 += (int)(m * (maxdim - *x0)); /* adjust so point is on the right boundary */
- *x0 = maxdim;
+ *x0 = maxdim;
/* now, perhaps, adjust the end of the line */
if (*x1 < 0) {
*y1 -= (int)(m * *x1);
x1 = x - hx;
x2 = x1 + gdImageSX(im->brush);
srcy = 0;
-
+
if (im->trueColor) {
if (im->brush->trueColor) {
for (ly = y1; ly < y2; ly++) {
if (p != gdImageGetTransparent(im->brush)) {
/* Truecolor brush. Very slow on a palette destination. */
if (im->brush->trueColor) {
- gdImageSetPixel(im, lx, ly, gdImageColorResolveAlpha(im, gdTrueColorGetRed(p),
- gdTrueColorGetGreen(p),
+ gdImageSetPixel(im, lx, ly, gdImageColorResolveAlpha(im, gdTrueColorGetRed(p),
+ gdTrueColorGetGreen(p),
gdTrueColorGetBlue(p),
gdTrueColorGetAlpha(p)));
} else {
float p_dist, p_alpha;
unsigned char opacity;
- /*
- * Find the perpendicular distance from point C (px, py) to the line
+ /*
+ * Find the perpendicular distance from point C (px, py) to the line
* segment AB that is being drawn. (Adapted from an algorithm from the
* comp.graphics.algorithms FAQ.)
*/
int By_Cy = im->AAL_y2 - py;
/* 2.0.13: bounds check! AA_opacity is just as capable of
- * overflowing as the main pixel array. Arne Jorgensen.
+ * overflowing as the main pixel array. Arne Jorgensen.
* 2.0.14: typo fixed. 2.0.15: moved down below declarations
* to satisfy non-C++ compilers.
*/
LBC_2 = (Bx_Cx * Bx_Cx) + (By_Cy * By_Cy);
if (((im->AAL_LAB_2 + LAC_2) >= LBC_2) && ((im->AAL_LAB_2 + LBC_2) >= LAC_2)) {
- /* The two angles are acute. The point lies inside the portion of the
+ /* The two angles are acute. The point lies inside the portion of the
* plane spanned by the line segment.
*/
p_dist = fabs ((float) ((Ay_Cy * im->AAL_Bx_Ax) - (Ax_Cx * im->AAL_By_Ay)) / im->AAL_LAB);
} else {
- /* The point is past an end of the line segment. It's length from the
+ /* The point is past an end of the line segment. It's length from the
* segment is the shorter of the lengths from the endpoints, but call
* the distance -1, so as not to compute the alpha nor draw the pixel.
*/
im->AAL_LAB = sqrt (im->AAL_LAB_2);
/* For AA, we must draw pixels outside the width of the line. Keep in
- * mind that this will be curtailed by cos/sin of theta later.
+ * mind that this will be curtailed by cos/sin of theta later.
*/
thick += 4;
}
-
+
dx = abs(x2 - x1);
dy = abs(y2 - y1);
if (dy <= dx) {
}
} else {
/* More-or-less vertical. use wid for horizontal stroke */
- /* 2.0.12: Michael Schwartz: divide rather than multiply;
+ /* 2.0.12: Michael Schwartz: divide rather than multiply;
TBB: but watch out for /0! */
double as = sin(atan2(dy, dx));
if (as != 0) {
BLEND_COLOR(t, dg, g, dg);
BLEND_COLOR(t, db, b, db);
im->tpixels[y][x]=gdTrueColorAlpha(dr, dg, db, gdAlphaOpaque);
-}
+}
/*
* Added on 2003/12 by Pierre-Alain Joye (pajoye@pearfr.org)
/* s and e are integers modulo 360 (degrees), with 0 degrees
being the rightmost extreme and degrees changing clockwise.
- cx and cy are the center in pixels; w and h are the horizontal
+ cx and cy are the center in pixels; w and h are the horizontal
and vertical diameter in pixels. Nice interface, but slow.
- See gd_arc_f_buggy.c for a better version that doesn't
+ See gd_arc_f_buggy.c for a better version that doesn't
seem to be bug-free yet. */
void gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color)
void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
{
int x, y;
-
+
/* Nick Atty: limit the points at the edge. Note that this also
* nicely kills any plotting for rectangles completely outside the
- * window as it makes the tests in the for loops fail
+ * window as it makes the tests in the for loops fail
*/
if (x1 < 0) {
x1 = 0;
if (dst->trueColor) {
/* 2.0: much easier when the destination is truecolor. */
/* 2.0.10: needs a transparent-index check that is still valid if
- * the source is not truecolor. Thanks to Frank Warmerdam.
+ * the source is not truecolor. Thanks to Frank Warmerdam.
*/
-
+
if (src->trueColor) {
for (y = 0; (y < h); y++) {
for (x = 0; (x < w); x++) {
/* Have we established a mapping for this color? */
if (src->trueColor) {
/* 2.05: remap to the palette available in the destination image. This is slow and
- * works badly, but it beats crashing! Thanks to Padhrig McCarthy.
+ * works badly, but it beats crashing! Thanks to Padhrig McCarthy.
*/
mapTo = gdImageColorResolveAlpha (dst, gdTrueColorGetRed (c), gdTrueColorGetGreen (c), gdTrueColorGetBlue (c), gdTrueColorGetAlpha (c));
} else if (colorMap[c] == (-1)) {
nc = gdImageColorResolveAlpha (dst, src->red[c], src->green[c], src->blue[c], src->alpha[c]);
}
colorMap[c] = nc;
- mapTo = colorMap[c];
+ mapTo = colorMap[c];
} else {
- mapTo = colorMap[c];
+ mapTo = colorMap[c];
}
gdImageSetPixel (dst, tox, toy, mapTo);
tox++;
tox++;
continue;
}
- /*
- * If it's the same image, mapping is NOT trivial since we
- * merge with greyscale target, but if pct is 100, the grey
- * value is not used, so it becomes trivial. pjw 2.0.12.
+ /*
+ * If it's the same image, mapping is NOT trivial since we
+ * merge with greyscale target, but if pct is 100, the grey
+ * value is not used, so it becomes trivial. pjw 2.0.12.
*/
if (dst == src && pct == 100) {
nc = c;
stx = (int *) gdMalloc (sizeof (int) * srcW);
sty = (int *) gdMalloc (sizeof (int) * srcH);
accum = 0;
-
+
/* Fixed by Mao Morimoto 2.0.16 */
for (i = 0; (i < srcW); i++) {
stx[i] = dstW * (i+1) / srcW - dstW * i / srcW ;
if (gdImageGetTransparent (src) == tmp) {
tox++;
continue;
- }
+ }
} else {
/* TK: old code follows */
mapTo = gdImageGetTrueColorPixel (src, x, y);
tox++;
continue;
}
- }
+ }
} else {
c = gdImageGetPixel (src, x, y);
/* Added 7/24/95: support transparent copies */
}
pcontribution = xportion * yportion;
p = gdImageGetTrueColorPixel(src, (int) sx + srcX, (int) sy + srcY);
-
+
alpha_factor = ((gdAlphaMax - gdTrueColorGetAlpha(p))) * pcontribution;
red += gdTrueColorGetRed (p) * alpha_factor;
green += gdTrueColorGetGreen (p) * alpha_factor;
sx += 1.0f;
}
while (sx < sx2);
-
+
sy += 1.0f;
}
-
+
while (sy < sy2);
-
+
if (spixels != 0.0f) {
red /= spixels;
green /= spixels;
if ( alpha_sum != 0.0f) {
if( contrib_sum != 0.0f) {
alpha_sum /= contrib_sum;
- }
+ }
red /= alpha_sum;
green /= alpha_sum;
blue /= alpha_sum;
/*
- * Rotate function Added on 2003/12
+ * Rotate function Added on 2003/12
* by Pierre-Alain Joye (pajoye@pearfr.org)
**/
/* Begin rotate function */
} else {
fill_color = c;
}
-
+
if (!im->polyAllocated) {
im->polyInts = (int *) gdMalloc(sizeof(int) * n);
im->polyAllocated = n;
}
if (maxy >= gdImageSY(im)) {
maxy = gdImageSY(im) - 1;
- }
+ }
/* Fix in 1.3: count a vertex only once */
for (y = miny; y <= maxy; y++) {
int
gdAlphaBlend (int dst, int src)
{
- /* 2.0.12: TBB: alpha in the destination should be a
+ /* 2.0.12: TBB: alpha in the destination should be a
* component of the result. Thanks to Frank Warmerdam for
* pointing out the issue.
*/
static int gdAlphaOverlayColor (int src, int dst, int max )
{
/* this function implements the algorithm
- *
+ *
* for dst[rgb] < 0.5,
* c[rgb] = 2.src[rgb].dst[rgb]
* and for dst[rgb] > 0.5,
* c[rgb] = -2.src[rgb].dst[rgb] + 2.dst[rgb] + 2.src[rgb] - 1
- *
+ *
*/
dst = dst << 1;
}
-/* Filters function added on 2003/12
+/* Filters function added on 2003/12
* by Pierre-Alain Joye (pajoye@pearfr.org)
**/
/* Begin filters function */
if (src==NULL) {
return 0;
}
-
+
f = GET_PIXEL_FUNCTION(src);
for (y=0; y<src->sy; ++y) {
g = gdImageGreen(src, pxl);
b = gdImageBlue(src, pxl);
a = gdImageAlpha(src, pxl);
-
+
new_pxl = gdImageColorAllocateAlpha(src, 255-r, 255-g, 255-b, a);
if (new_pxl == -1) {
new_pxl = gdImageColorClosestAlpha(src, 255-r, 255-g, 255-b, a);
if (src==NULL || (brightness < -255 || brightness>255)) {
return 0;
}
-
+
if (brightness==0) {
return 1;
}
for (y=0; y<src->sy; ++y) {
for (x=0; x<src->sx; ++x) {
pxl = f (src, x, y);
-
+
r = gdImageRed(src, pxl);
g = gdImageGreen(src, pxl);
b = gdImageBlue(src, pxl);
a = gdImageAlpha(src, pxl);
-
+
r = r + brightness;
g = g + brightness;
b = b + brightness;
-
+
r = (r > 255)? 255 : ((r < 0)? 0:r);
g = (g > 255)? 255 : ((g < 0)? 0:g);
b = (b > 255)? 255 : ((b < 0)? 0:b);
if (src==NULL) {
return 0;
}
-
+
contrast = (double)(100.0-contrast)/100.0;
contrast = contrast*contrast;
-
+
for (y=0; y<src->sy; ++y) {
for (x=0; x<src->sx; ++x) {
- pxl = f(src, x, y);
-
+ pxl = f(src, x, y);
+
r = gdImageRed(src, pxl);
g = gdImageGreen(src, pxl);
b = gdImageBlue(src, pxl);
bf = bf*contrast;
bf = bf+0.5;
bf = bf*255.0;
-
+
gf = (double)g/255.0;
gf = gf-0.5;
gf = gf*contrast;
if (src==NULL || (red<-255||red>255) || (green<-255||green>255) || (blue<-255||blue>255)) {
return 0;
}
-
+
f = GET_PIXEL_FUNCTION(src);
-
+
for (y=0; y<src->sy; ++y) {
for (x=0; x<src->sx; ++x) {
- pxl = f(src, x, y);
+ pxl = f(src, x, y);
r = gdImageRed(src, pxl);
g = gdImageGreen(src, pxl);
b = gdImageBlue(src, pxl);
/* We need the orinal image with each safe neoghb. pixel */
srcback = gdImageCreateTrueColor (src->sx, src->sy);
gdImageCopy(srcback, src,0,0,0,0,src->sx,src->sy);
-
+
if (srcback==NULL) {
return 0;
}
for(x=0; x<src->sx; x++) {
new_r = new_g = new_b = 0;
new_a = gdImageAlpha(srcback, pxl);
-
+
for (j=0; j<3; j++) {
for (i=0; i<3; i++) {
- pxl = f(srcback, x-(3>>1)+i, y-(3>>1)+j);
+ pxl = f(srcback, x-(3>>1)+i, y-(3>>1)+j);
new_r += (float)gdImageRed(srcback, pxl) * filter[j][i];
new_g += (float)gdImageGreen(srcback, pxl) * filter[j][i];
new_b += (float)gdImageBlue(srcback, pxl) * filter[j][i];
}
- }
-
+ }
+
new_r = (new_r/filter_div)+offset;
new_g = (new_g/filter_div)+offset;
new_b = (new_b/filter_div)+offset;
}
}
}
- gdImageDestroy(srcback);
- return 1;
+ gdImageDestroy(srcback);
+ return 1;
}
int gdImageSelectiveBlur( gdImagePtr src)
if (src==NULL) {
return 0;
}
-
+
/* We need the orinal image with each safe neoghb. pixel */
srcback = gdImageCreateTrueColor (src->sx, src->sy);
gdImageCopy(srcback, src,0,0,0,0,src->sx,src->sy);
-
+
if (srcback==NULL) {
return 0;
}
for(y = 0; y<src->sy; y++) {
for (x=0; x<src->sx; x++) {
flt_r_sum = flt_g_sum = flt_b_sum = 0.0;
- cpxl = f(src, x, y);
+ cpxl = f(src, x, y);
for (j=0; j<3; j++) {
for (i=0; i<3; i++) {
if ((j == 1) && (i == 1)) {
flt_r[1][1] = flt_g[1][1] = flt_b[1][1] = 0.5;
} else {
- pxl = f(src, x-(3>>1)+i, y-(3>>1)+j);
+ pxl = f(src, x-(3>>1)+i, y-(3>>1)+j);
new_a = gdImageAlpha(srcback, pxl);
new_r = ((float)gdImageRed(srcback, cpxl)) - ((float)gdImageRed (srcback, pxl));
-
+
if (new_r < 0.0f) {
new_r = -new_r;
- }
+ }
if (new_r != 0) {
flt_r[j][i] = 1.0f/new_r;
} else {
flt_r[j][i] = 1.0f;
- }
+ }
new_g = ((float)gdImageGreen(srcback, cpxl)) - ((float)gdImageGreen(srcback, pxl));
-
+
if (new_g < 0.0f) {
new_g = -new_g;
- }
+ }
if (new_g != 0) {
flt_g[j][i] = 1.0f/new_g;
} else {
flt_g[j][i] = 1.0f;
- }
+ }
new_b = ((float)gdImageBlue(srcback, cpxl)) - ((float)gdImageBlue(srcback, pxl));
if (new_b < 0.0f) {
new_b = -new_b;
- }
+ }
if (new_b != 0) {
flt_b[j][i] = 1.0f/new_b;
} else {
flt_b[j][i] = 1.0f;
}
}
-
+
flt_r_sum += flt_r[j][i];
flt_g_sum += flt_g[j][i];
flt_b_sum += flt_b [j][i];
}
}
-
+
for (j=0; j<3; j++) {
for (i=0; i<3; i++) {
if (flt_r_sum != 0.0) {
flt_r[j][i] /= flt_r_sum;
- }
+ }
if (flt_g_sum != 0.0) {
flt_g[j][i] /= flt_g_sum;
- }
+ }
if (flt_b_sum != 0.0) {
flt_b [j][i] /= flt_b_sum;
- }
+ }
}
}
new_r = new_g = new_b = 0.0;
-
+
for (j=0; j<3; j++) {
for (i=0; i<3; i++) {
pxl = f(src, x-(3>>1)+i, y-(3>>1)+j);
}
if ((y >= 0) && (y < src->sy)) {
gdImageSetPixel (src, x, y, new_pxl);
- }
+ }
}
}
gdImageDestroy(srcback);
float filter[3][3] = {{1.0,1.0,1.0},
{0.0,0.0,0.0},
{-1.0,-1.0,-1.0}};
-
+
return gdImageConvolution(src, filter, 1, 127);
}
float filter[3][3] = {{1.0,2.0,1.0},
{2.0,4.0,2.0},
{1.0,2.0,1.0}};
-
- return gdImageConvolution(im, filter, 16, 0);
+
+ return gdImageConvolution(im, filter, 16, 0);
}
int gdImageEmboss(gdImagePtr im)
float filter[3][3] = {{-1.0,0.0,-1.0},
{0.0,4.0,0.0},
{-1.0,0.0,-1.0}};
-
+
return gdImageConvolution(im, filter, 1, 127);
}
float filter[3][3] = {{-1.0,-1.0,-1.0},
{-1.0,9.0,-1.0},
{-1.0,-1.0,-1.0}};
-
+
return gdImageConvolution(im, filter, 1, 0);
}
float filter[3][3] = {{1.0,1.0,1.0},
{1.0,0.0,1.0},
{1.0,1.0,1.0}};
-
+
filter[1][1] = weight;
-
+
return gdImageConvolution(im, filter, weight+8, 0);
}
/* End filters function */
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. This software is provided "AS IS." Thomas Boutell and
- * Boutell.Com, Inc. disclaim all warranties, either express or implied,
- * including but not limited to implied warranties of merchantability and
+ * Boutell.Com, Inc. disclaim all warranties, either express or implied,
+ * including but not limited to implied warranties of merchantability and
* fitness for a particular purpose, with respect to this code and accompanying
* documentation. */
/* Image type. See functions below; you will not need to change
the elements directly. Use the provided macros to
- access sx, sy, the color table, and colorsTotal for
+ access sx, sy, the color table, and colorsTotal for
read-only purposes. */
-/* If 'truecolor' is set true, the image is truecolor;
+/* If 'truecolor' is set true, the image is truecolor;
pixels are represented by integers, which
- must be 32 bits wide or more.
+ must be 32 bits wide or more.
True colors are repsented as follows:
ARGB
Where 'A' (alpha channel) occupies only the
- LOWER 7 BITS of the MSB. This very small
+ LOWER 7 BITS of the MSB. This very small
loss of alpha channel resolution allows gd 2.x
to keep backwards compatibility by allowing
signed integers to be used to represent colors,
#define gdEffectOverlay 3
-/* This function accepts truecolor pixel values only. The
+/* This function accepts truecolor pixel values only. The
source color is composited with the destination color
based on the alpha channel value of the source color.
The resulting color is opaque. */
int colorsTotal;
int red[gdMaxColors];
int green[gdMaxColors];
- int blue[gdMaxColors];
+ int blue[gdMaxColors];
int open[gdMaxColors];
/* For backwards compatibility, this is set to the
first palette entry with 100% transparency,
- and is also set and reset by the
+ and is also set and reset by the
gdImageColorTransparent function. Newer
applications can allocate palette entries
with any desired level of transparency; however,
int *polyInts;
int polyAllocated;
struct gdImageStruct *brush;
- struct gdImageStruct *tile;
+ struct gdImageStruct *tile;
int brushColorMap[gdMaxColors];
int tileColorMap[gdMaxColors];
int styleLength;
really support multiple levels of transparency in
palettes, to my knowledge, as of 2/15/01. Most
common browsers will display 100% opaque and
- 100% transparent correctly, and do something
+ 100% transparent correctly, and do something
unpredictable and/or undesirable for levels
in between. TBB */
- int alpha[gdMaxColors];
+ int alpha[gdMaxColors];
/* Truecolor flag and pixels. New 2.0 fields appear here at the
end to minimize breakage of existing object code. */
int trueColor;
/* Should alpha channel be copied, or applied, each time a
pixel is drawn? This applies to truecolor images only.
No attempt is made to alpha-blend in palette images,
- even if semitransparent palette entries exist.
+ even if semitransparent palette entries exist.
To do that, build your image as a truecolor image,
then quantize down to 8 bits. */
int alphaBlendingFlag;
PNG at the moment; other future formats may also
have that capability. JPEG doesn't. */
int saveAlphaFlag;
-
+
/* 2.0.12: anti-aliased globals */
int AA;
unsigned char **AA_opacity;
int AA_polygon;
/* Stored and pre-computed variables for determining the perpendicular
- * distance from a point to the anti-aliased line being drawn:
+ * distance from a point to the anti-aliased line being drawn:
*/
int AAL_x1;
int AAL_y1;
gdImagePtr gdImageCreateFromPng(FILE *fd);
gdImagePtr gdImageCreateFromPngCtx(gdIOCtxPtr in);
gdImagePtr gdImageCreateFromWBMP(FILE *inFile);
-gdImagePtr gdImageCreateFromWBMPCtx(gdIOCtx *infile);
+gdImagePtr gdImageCreateFromWBMPCtx(gdIOCtx *infile);
gdImagePtr gdImageCreateFromJpeg(FILE *infile);
gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile);
/* Replaces or blends with the background depending on the
most recent call to gdImageAlphaBlending and the
- alpha channel value of 'color'; default is to overwrite.
+ alpha channel value of 'color'; default is to overwrite.
Tiling and line styling are also implemented
- here. All other gd drawing functions pass through this call,
+ here. All other gd drawing functions pass through this call,
allowing for many useful effects. */
-
+
void gdImageSetPixel(gdImagePtr im, int x, int y, int color);
int gdImageGetPixel(gdImagePtr im, int x, int y);
void gdImageStringUp16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
/* 2.0.16: for thread-safe use of gdImageStringFT and friends,
- * call this before allowing any thread to call gdImageStringFT.
+ * call this before allowing any thread to call gdImageStringFT.
* Otherwise it is invoked by the first thread to invoke
- * gdImageStringFT, with a very small but real risk of a race condition.
+ * gdImageStringFT, with a very small but real risk of a race condition.
* Return 0 on success, nonzero on failure to initialize freetype.
*/
int gdFontCacheSetup(void);
void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c);
void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c);
-/* These functions still work with truecolor images,
+/* These functions still work with truecolor images,
for which they never return error. */
int gdImageColorAllocate(gdImagePtr im, int r, int g, int b);
/* gd 2.0: palette entries with non-opaque transparency are permitted. */
/* 2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all,
* 1 is FASTEST but produces larger files, 9 provides the best
* compression (smallest files) but takes a long time to compress, and
- * -1 selects the default compiled into the zlib library.
+ * -1 selects the default compiled into the zlib library.
*/
void gdImagePngEx(gdImagePtr im, FILE * out, int level);
void gdImagePngCtxEx(gdImagePtr im, gdIOCtx * out, int level);
gdArc and gdChord are mutually exclusive;
gdChord just connects the starting and ending
angles with a straight line, while gdArc produces
- a rounded edge. gdPie is a synonym for gdArc.
+ a rounded edge. gdPie is a synonym for gdArc.
gdNoFill indicates that the arc or chord should be
outlined, not filled. gdEdged, used together with
gdNoFill, indicates that the beginning and ending
void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color);
void gdImageFill(gdImagePtr im, int x, int y, int color);
void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h);
-void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
+void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
int srcX, int srcY, int w, int h, int pct);
void gdImageCopyMergeGray(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
int srcX, int srcY, int w, int h, int pct);
destination pixel, taking into account what portion of the
destination pixel each source pixel represents. This is a
floating point operation, but this is not a performance issue
- on modern hardware, except for some embedded devices. If the
- destination is a palette image, gdImageCopyResized is
+ on modern hardware, except for some embedded devices. If the
+ destination is a palette image, gdImageCopyResized is
substituted automatically. */
void gdImageCopyResampled(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
void gdImageSetAntiAliased(gdImagePtr im, int c);
void gdImageSetAntiAliasedDontBlend(gdImagePtr im, int c, int dont_blend);
void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels);
-/* Line thickness (defaults to 1). Affects lines, ellipses,
+/* Line thickness (defaults to 1). Affects lines, ellipses,
rectangles, polygons and so forth. */
void gdImageSetThickness(gdImagePtr im, int thickness);
/* On or off (1 or 0) for all three of these. */
gdIOCtx* gdNewSSCtx(gdSourcePtr in, gdSinkPtr out);
void* gdDPExtractData(struct gdIOCtx* ctx, int *size);
-#define GD2_CHUNKSIZE 128
+#define GD2_CHUNKSIZE 128
#define GD2_CHUNKSIZE_MIN 64
#define GD2_CHUNKSIZE_MAX 4096
#define GD2_FMT_COMPRESSED 2
-/* filters section
+/* filters section
*
* Negate the imag src, white becomes black,
* The red, green, and blue intensities of an image are negated.
/* This is potentially great stuff, but fails against the test
- program at the end. This would probably be much more
- efficent than the implementation currently in gd.c if the
+ program at the end. This would probably be much more
+ efficent than the implementation currently in gd.c if the
errors in the output were corrected. TBB */
#if 0
#define WIDTH 500
#define HEIGHT 300
-int
+int
main (int argc, char *argv[])
{
gdImagePtr im = gdImageCreate (WIDTH, HEIGHT);
}
GD2_DBG(printf("Pallette had %d colours (T=%d)\n", im->colorsTotal, im->transparent));
-
+
if (im->trueColor) {
return TRUE;
}
static void _gdPutHeader (gdImagePtr im, gdIOCtx * out)
{
- /* 65535 indicates this is a gd 2.x .gd file.
+ /* 65535 indicates this is a gd 2.x .gd file.
* 2.0.12: 65534 indicates truecolor.
*/
if (im->trueColor) {
/* 2.11: not part of the API, as the save routine can figure it out
* from im->trueColor, and the load routine doesn't need to tell
* the end user the saved format. NOTE: adding 2 is assumed
- * to result in the correct format value for truecolor!
+ * to result in the correct format value for truecolor!
*/
#define GD2_FMT_TRUECOLOR_RAW 3
#define GD2_FMT_TRUECOLOR_COMPRESSED 4
return FALSE;
}
GD2_DBG(php_gd_error("Got chunk\n"));
-
+
return TRUE;
}
}
chunkBuf = gdCalloc(chunkMax, 1);
compBuf = gdCalloc(compMax, 1);
-
+
GD2_DBG(php_gd_error("Largest compressed chunk is %d bytes\n", compMax));
}
return 0;
}
-gdImagePtr gdImageCreateFromGd2Part (FILE * inFile, int srcx, int srcy, int w, int h)
+gdImagePtr gdImageCreateFromGd2Part (FILE * inFile, int srcx, int srcy, int w, int h)
{
gdImagePtr im;
gdIOCtx *in = gdNewFileCtx(inFile);
if (chunkMax <= 0) {
goto fail2;
}
-
+
chunkBuf = gdCalloc(chunkMax, 1);
compBuf = gdCalloc(compMax, 1);
}
/* Only use a point that is in the image. */
if ((x >= srcx) && (x < (srcx + w)) && (x < fsx) && (x >= 0) && (y >= srcy) && (y < (srcy + h)) && (y < fsy) && (y >= 0)) {
- if (im->trueColor) {
+ if (im->trueColor) {
im->tpixels[y - srcy][x - srcx] = ch;
} else {
im->pixels[y - srcy][x - srcx] = ch;
- }
+ }
}
}
}
if (chunkIdx) {
gdFree(chunkIdx);
}
-
+
return im;
fail2:
int compMax = 0;
/* Force fmt to a valid value since we don't return anything. */
- if ((fmt != GD2_FMT_RAW) && (fmt != GD2_FMT_COMPRESSED)) {
+ if ((fmt != GD2_FMT_RAW) && (fmt != GD2_FMT_COMPRESSED)) {
fmt = im->trueColor ? GD2_FMT_TRUECOLOR_COMPRESSED : GD2_FMT_COMPRESSED;
}
if (im->trueColor) {
chunkData = safe_emalloc(cs * bytesPerPixel, cs, 0);
memset(chunkData, 0, cs * bytesPerPixel * cs);
if (compMax <= 0) {
- goto fail;
+ goto fail;
}
compData = gdCalloc(compMax, 1);
/* Save the file position of chunk index, and allocate enough space for
- * each chunk_info block .
+ * each chunk_info block .
*/
idxPos = gdTell(out);
idxSize = ncx * ncy * sizeof(t_chunk_info);
}
} else {
for (x = xlo; x < xhi; x++) {
- GD2_DBG(php_gd_error("%d, ",x));
+ GD2_DBG(php_gd_error("%d, ",x));
if (im->trueColor) {
gdPutInt(im->tpixels[y][x], out);
}
}
}
- GD2_DBG(php_gd_error("y=%d done.\n",y));
+ GD2_DBG(php_gd_error("y=%d done.\n",y));
}
if (gd2_compressed(fmt)) {
if (chunkData) {
gdFree(chunkData);
}
- if (compData) {
+ if (compData) {
gdFree(compData);
}
if (chunkIdx) {
gdIOCtx *out = gdNewFileCtx(outFile);
_gdImageGd2(im, out, cs, fmt);
-
+
out->gd_free(out);
}
_gdImageGd2(im, out, cs, fmt);
rv = gdDPExtractData(out, size);
out->gd_free(out);
-
+
return rv;
}
}
im->interlace = BitSet(buf[8], INTERLACE);
if (! useGlobalColormap) {
- if (ReadColorMap(fd, bitPixel, localColorMap)) {
+ if (ReadColorMap(fd, bitPixel, localColorMap)) {
return 0;
}
- ReadImage(im, fd, imw, imh, localColorMap,
- BitSet(buf[8], INTERLACE));
+ ReadImage(im, fd, imw, imh, localColorMap,
+ BitSet(buf[8], INTERLACE));
/*1.4//imageCount != imageNumber); */
} else {
ReadImage(im, fd, imw, imh,
- ColorMap,
+ ColorMap,
BitSet(buf[8], INTERLACE));
/*1.4//imageCount != imageNumber); */
}
if (Transparent != (-1)) {
gdImageColorTransparent(im, Transparent);
- }
+ }
goto terminated;
}
} else {
break;
}
- }
+ }
return im;
}
int rv;
int i;
char *tmp = NULL;
-
+
rv = GetDataBlock_(fd,buf);
if (VERBOSE) {
if (rv > 0) {
if (done) {
if (curbit >= lastbit) {
/* Oh well */
- }
+ }
return -1;
}
buf[0] = buf[last_byte-2];
max_code = clear_code+2;
GetCode(fd, 0, TRUE);
-
+
fresh = TRUE;
for (i = 0; i < clear_code; ++i) {
static void
ReadImage(gdImagePtr im, gdIOCtx *fd, int len, int height, unsigned char (*cmap)[256], int interlace) /*1.4//, int ignore) */
{
- unsigned char c;
+ unsigned char c;
int v;
int xpos = 0, ypos = 0, pass = 0;
int i;
/* Stash the color map into the image */
for (i=0; (i<gdMaxColors); i++) {
- im->red[i] = cmap[CM_RED][i];
- im->green[i] = cmap[CM_GREEN][i];
- im->blue[i] = cmap[CM_BLUE][i];
+ im->red[i] = cmap[CM_RED][i];
+ im->green[i] = cmap[CM_GREEN][i];
+ im->blue[i] = cmap[CM_BLUE][i];
im->open[i] = 1;
}
/* Many (perhaps most) of these colors will remain marked open. */
** Initialize the Compression routines
*/
if (! ReadOK(fd,&c,1)) {
- return;
+ return;
}
if (LWZReadByte(fd, TRUE, c) < 0) {
return;
#ifdef VMS
#define Putchar gdPutchar
#endif
-
+
typedef struct gdIOCtx {
int (*getC)(struct gdIOCtx*);
int (*getBuf)(struct gdIOCtx*, void*, int);
dpIOCtx *dctx;
dctx = (dpIOCtx *) ctx;
-
+
return (dctx->dp->pos);
}
int bytesNeeded;
char *tmp;
- if (!dp->dataGood) {
+ if (!dp->dataGood) {
return FALSE;
}
* used internally until it settles down a bit.
*
* This module just layers the Source/Sink interface on top of the IOCtx; no
- * support is provided for tell/seek, so GD2 writing is not possible, and
+ * support is provided for tell/seek, so GD2 writing is not possible, and
* retrieving parts of GD2 files is also not possible.
*
* A new SS context does not need to be created with both a Source and a Sink.
res = ((lctx->src->source) (lctx->src->context, buf, size));
/*
- * Translate the return values from the Source object:
+ * Translate the return values from the Source object:
* 0 is EOF, -1 is error
*/
/*
* gd_jpeg.c: Read and write JPEG (JFIF) format image files using the
* gd graphics library (http://www.boutell.com/gd/).
- *
+ *
* This software is based in part on the work of the Independent JPEG
* Group. For more information on the IJG JPEG software (and JPEG
* documentation, etc.), see ftp://ftp.uu.net/graphics/jpeg/.
* major CGI brain damage
*
* 2.0.10: more efficient gdImageCreateFromJpegCtx, thanks to
- * Christian Aberger
+ * Christian Aberger
*/
#include <stdio.h>
void jpeg_gdIOCtx_src (j_decompress_ptr cinfo, gdIOCtx * infile);
-/*
+/*
* Create a gd-format image from the JPEG-format INFILE. Returns the
* image, or NULL upon error.
*/
jpeg_gdIOCtx_src (&cinfo, infile);
retval = jpeg_read_header (&cinfo, TRUE);
- if (retval != JPEG_HEADER_OK) {
+ if (retval != JPEG_HEADER_OK) {
php_gd_error_ex(E_WARNING, "gd-jpeg: warning: jpeg_read_header returned %d, expected %d", retval, JPEG_HEADER_OK);
}
* latest libjpeg, replaced by something else. Unfortunately
* there is still no right way to find out if the file was
* progressive or not; just declare your intent before you
- * write one by calling gdImageInterlace(im, 1) yourself.
+ * write one by calling gdImageInterlace(im, 1) yourself.
* After all, we're not really supposed to rework JPEGs and
- * write them out again anyway. Lossy compression, remember?
+ * write them out again anyway. Lossy compression, remember?
*/
#if 0
gdImageInterlace (im, cinfo.progressive_mode != 0);
int got = gdGetBuf(src->buffer + nbytes, INPUT_BUF_SIZE - nbytes, src->infile);
if (got == EOF || got == 0) {
- /* EOF or error. If we got any data, don't worry about it. If we didn't, then this is unexpected. */
+ /* EOF or error. If we got any data, don't worry about it. If we didn't, then this is unexpected. */
if (!nbytes) {
nbytes = -1;
}
}
nbytes += got;
}
-
+
if (nbytes <= 0) {
if (src->start_of_file) { /* Treat empty input file as fatal error */
ERREXIT (cinfo, JERR_INPUT_EMPTY);
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof (my_source_mgr));
src = (my_src_ptr) cinfo->src;
src->buffer = (unsigned char *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, INPUT_BUF_SIZE * sizeof (unsigned char));
-
+
}
src = (my_src_ptr) cinfo->src;
out all fprintf() statements to disable that).
GD 2.0 supports RGBA truecolor and will read and write truecolor PNGs.
- GD 2.0 supports 8 bits of color resolution per channel and
+ GD 2.0 supports 8 bits of color resolution per channel and
7 bits of alpha channel resolution. Images with more than 8 bits
per channel are reduced to 8 bits. Images with an alpha channel are
only able to resolve down to '1/128th opaque' instead of '1/256th',
memset (infile, 0, sizeof(infile));
/* first do a quick check that the file really is a PNG image; could
- * have used slightly more general png_sig_cmp() function instead
+ * have used slightly more general png_sig_cmp() function instead
*/
gdGetBuf(sig, 8, infile);
if (!png_check_sig (sig, 8)) { /* bad signature */
/* we could create a second info struct here (end_info), but it's only
* useful if we want to keep pre- and post-IDAT chunk info separated
- * (mainly for PNG-aware image editors and converters)
+ * (mainly for PNG-aware image editors and converters)
*/
/* setjmp() must be called in every non-callback function that calls a
#endif /* DEBUG */
if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) {
/* gd 2.0: we support this rather thoroughly now. Grab the
- * first fully transparent entry, if any, as the value of
+ * first fully transparent entry, if any, as the value of
* the simple-transparency index, mostly for backwards
* binary compatibility. The alpha channel is where it's
* really at these days.
* 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.)
+ * image in existence.)
*/
}
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
/* gd 2.0: we now support truecolor. See the comment above
* for a rare situation in which the transparent pixel may not
- * work properly with 16-bit channels.
+ * work properly with 16-bit channels.
*/
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
png_get_tRNS(png_ptr, info_ptr, NULL, NULL, &trans_color_rgb);
if (bit_depth == 16) { /* png_set_strip_16() not yet in effect */
- transparent = gdTrueColor(trans_color_rgb->red >> 8,
+ transparent = gdTrueColor(trans_color_rgb->red >> 8,
trans_color_rgb->green >> 8,
trans_color_rgb->blue >> 8);
} else {
- transparent = gdTrueColor(trans_color_rgb->red,
+ transparent = gdTrueColor(trans_color_rgb->red,
trans_color_rgb->green,
trans_color_rgb->blue);
}
register png_byte b = row_pointers[h][boffset++];
/* gd has only 7 bits of alpha channel resolution, and
- * 127 is transparent, 0 opaque. A moment of convenience,
+ * 127 is transparent, 0 opaque. A moment of convenience,
* a lifetime of compatibility.
*/
* gd is intentionally imperfect and doesn't spend a lot of time
* fussing with such things.
*/
-
+
/* png_set_filter(png_ptr, 0, PNG_FILTER_NONE); */
/* 2.0.12: this is finally a parameter */
png_set_compression_level(png_ptr, level);
/* can set this to a smaller value without compromising compression if all
- * image data is 16K or less; will save some decoder memory [min == 8]
+ * image data is 16K or less; will save some decoder memory [min == 8]
*/
/* png_set_compression_window_bits(png_ptr, 15); */
bit_depth = 1;
} else if (colors <= 4) {
bit_depth = 2;
- } else if (colors <= 16) {
+ } else if (colors <= 16) {
bit_depth = 4;
} else {
bit_depth = 8;
}
}
-
+
interlace_type = im->interlace ? PNG_INTERLACE_ADAM7 : PNG_INTERLACE_NONE;
if (im->trueColor) {
if (!im->trueColor) {
/* Oy veh. Remap the PNG palette to put the entries with interesting alpha channel
* values first. This minimizes the size of the tRNS chunk and thus the size
- * of the PNG file as a whole.
+ * of the PNG file as a whole.
*/
-
+
int tc = 0;
int i;
int j;
for (i = 0; i < im->colorsTotal; i++) {
if (!im->open[i]) {
if (im->alpha[i] != gdAlphaOpaque) {
- /* Andrew Hull: >> 6, not >> 7! (gd 2.0.5) */
+ /* Andrew Hull: >> 6, not >> 7! (gd 2.0.5) */
trans_values[j] = 255 - ((im->alpha[i] << 1) + (im->alpha[i] >> 6));
mapping[i] = j++;
} else {
* PNG's convention in which 255 is opaque.
*/
a = gdTrueColorGetAlpha(thisPixel);
- /* Andrew Hull: >> 6, not >> 7! (gd 2.0.5) */
+ /* Andrew Hull: >> 6, not >> 7! (gd 2.0.5) */
*pOutputRow++ = 255 - ((a << 1) + (a >> 6));
}
}
for (j = 0; j < height; ++j) {
gdFree(row_pointers[j]);
}
-
+
gdFree(row_pointers);
} else {
if (remap) {
* If it is not working, it's not Thomas G. Lane's fault.
*/
-/*
+/*
* SETTING THIS ONE CAUSES STRIPED IMAGE
* to be done: solve this
* #define ORIGINAL_LIB_JPEG_REVERSE_ODD_ROWS
* color space, and repeatedly splits the "largest" remaining box until we
* have as many boxes as desired colors. Then the mean color in each
* remaining box becomes one of the possible output colors.
- *
+ *
* The second pass over the image maps each input pixel to the closest output
* color (optionally after applying a Floyd-Steinberg dithering correction).
* This mapping is logically trivial, but making it go fast enough requires
for (c2 = c2max; c2 >= c2min; c2--) {
for (c0 = c0min; c0 <= c0max; c0++) {
histp = &histogram[c0][c1min][c2];
- for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) {
+ for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) {
if (*histp != 0) {
boxp->c2max = c2max = c2;
goto have_c2max;
*outptr++ = (JSAMPLE) (*cachep - 1);
#else
*outptr++ = (*cachep - 1);
-#endif
+#endif
}
}
}
}
im->pixels = 0;
}
-
+
for (i = 0; i < HIST_C0_ELEMS; i++) {
if (cquantize->histogram[i]) {
gdFree(cquantize->histogram[i]);
/*
WBMP: Wireless Bitmap Type 0: B/W, Uncompressed Bitmap
- Specification of the WBMP format can be found in the file:
+ Specification of the WBMP format can be found in the file:
SPEC-WAESpec-19990524.pdf
- You can download the WAP specification on: http://www.wapforum.com/
+ You can download the WAP specification on: http://www.wapforum.com/
gd_wbmp.c
(wbmp library included, but you can find the latest distribution
at http://www.vandenbrande.com/wbmp)
- Implemented: gdImageCreateFromWBMPCtx, gdImageCreateFromWBMP
+ Implemented: gdImageCreateFromWBMPCtx, gdImageCreateFromWBMP
---------------------------------------------------------------------------
** implied warranty.
---------------------------------------------------------------------------
- Parts od this code are inspired by 'pbmtowbmp.c' and 'wbmptopbm.c' by
+ Parts od this code are inspired by 'pbmtowbmp.c' and 'wbmptopbm.c' by
Terje Sannum <terje@looplab.com>.
**
** Permission to use, copy, modify, and distribute this software and its
** Write the image as a wbmp file
** Parameters are:
** image: gd image structure;
- ** fg: the index of the foreground color. any other value will be
+ ** fg: the index of the foreground color. any other value will be
** considered as background and will not be written
** out: the stream where to write
*/
gdImageWBMPCtx(im, fg, out);
rv = gdDPExtractData(out, size);
out->gd_free(out);
-
+
return rv;
}
#ifdef NEED_CACHE
-/*
+/*
* gdcache.c
*
- * Caches of pointers to user structs in which the least-recently-used
- * element is replaced in the event of a cache miss after the cache has
+ * Caches of pointers to user structs in which the least-recently-used
+ * element is replaced in the event of a cache miss after the cache has
* reached a given size.
*
* John Ellson (ellson@graphviz.org) Oct 31, 1997
* The head structure has a pointer to the most-recently-used
* element, and elements are moved to this position in the list each
* time they are used. The head also contains pointers to three
- * user defined functions:
- * - a function to test if a cached userdata matches some keydata
- * - a function to provide a new userdata struct to the cache
+ * user defined functions:
+ * - a function to test if a cached userdata matches some keydata
+ * - a function to provide a new userdata struct to the cache
* if there has been a cache miss.
* - a function to release a userdata struct when it is
* no longer being managed by the cache
*
* In the event of a cache miss the cache is allowed to grow up to
* a specified maximum size. After the maximum size is reached then
- * the least-recently-used element is discarded to make room for the
- * new. The most-recently-returned value is always left at the
+ * the least-recently-used element is discarded to make room for the
+ * new. The most-recently-returned value is always left at the
* beginning of the list after retrieval.
*
* In the current implementation the cache is traversed by a linear
-/*
+/*
* gdcache.h
*
- * Caches of pointers to user structs in which the least-recently-used
- * element is replaced in the event of a cache miss after the cache has
+ * Caches of pointers to user structs in which the least-recently-used
+ * element is replaced in the event of a cache miss after the cache has
* reached a given size.
*
* John Ellson (ellson@graphviz.org) Oct 31, 1997
* The head structure has a pointer to the most-recently-used
* element, and elements are moved to this position in the list each
* time they are used. The head also contains pointers to three
- * user defined functions:
- * - a function to test if a cached userdata matches some keydata
- * - a function to provide a new userdata struct to the cache
+ * user defined functions:
+ * - a function to test if a cached userdata matches some keydata
+ * - a function to provide a new userdata struct to the cache
* if there has been a cache miss.
* - a function to release a userdata struct when it is
* no longer being managed by the cache
*
* In the event of a cache miss the cache is allowed to grow up to
* a specified maximum size. After the maximum size is reached then
- * the least-recently-used element is discarded to make room for the
- * new. The most-recently-returned value is always left at the
+ * the least-recently-used element is discarded to make room for the
+ * new. The most-recently-returned value is always left at the
* beginning of the list after retrieval.
*
* In the current implementation the cache is traversed by a linear
gdImageStringTTF (gdImage * im, int *brect, int fg, char *fontlist,
double ptsize, double angle, int x, int y, char *string)
{
- /* 2.0.6: valid return */
- return gdImageStringFT (im, brect, fg, fontlist, ptsize,
- angle, x, y, string);
+ /* 2.0.6: valid return */
+ return gdImageStringFT (im, brect, fg, fontlist, ptsize, angle, x, y, string);
}
#ifndef HAVE_LIBFREETYPE
double ptsize, double angle, int x, int y, char *string,
gdFTStringExtraPtr strex)
{
- return "libgd was not built with FreeType font support\n";
+ return "libgd was not built with FreeType font support\n";
}
char *
gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
double ptsize, double angle, int x, int y, char *string)
{
- return "libgd was not built with FreeType font support\n";
+ return "libgd was not built with FreeType font support\n";
}
#else
#define TWEENCOLORCACHESIZE 32
/*
- * Line separation as a factor of font height.
- * No space between if LINESPACE = 1.00
+ * 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
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;
+ 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;
+{
+ char *fontlist; /* key */
+ FT_Library *library;
+} fontkey_t;
typedef struct
- {
- int pixel; /* key */
- int bgcolor; /* key */
- int fgcolor; /* key *//* -ve means no antialias */
- gdImagePtr im; /* key */
- int tweencolor;
- }
-tweencolor_t;
+{
+ int pixel; /* key */
+ int bgcolor; /* key */
+ int fgcolor; /* key *//* -ve means no antialias */
+ gdImagePtr im; /* key */
+ int tweencolor;
+} tweencolor_t;
typedef struct
- {
- int pixel; /* key */
- int bgcolor; /* key */
- int fgcolor; /* key *//* -ve means no antialias */
- gdImagePtr im; /* key */
- }
-tweencolorkey_t;
+{
+ int pixel; /* key */
+ int bgcolor; /* key */
+ int fgcolor; /* key *//* -ve means no antialias */
+ gdImagePtr im; /* key */
+} tweencolorkey_t;
/********************************************************************
* gdTcl_UtfToUniChar is borrowed from Tcl ...
#define Tcl_UniChar int
#define TCL_UTF_MAX 3
-static int
-gdTcl_UtfToUniChar (char *str, Tcl_UniChar * chPtr)
+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');
+ 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;
+ }
}
- else
- break;
- }
- if (byte == ';')
- {
- *chPtr = (Tcl_UniChar) n;
- return ++i;
- }
}
- }
- /*
- * Unroll 1 to 3 byte UTF-8 sequences, use loop to handle longer ones.
- */
+ /* Unroll 1 to 3 byte UTF-8 sequences, use loop to handle longer ones. */
- byte = *((unsigned char *) str);
+ byte = *((unsigned char *) str);
#ifdef JISX0208
- if (0xA1 <= byte && byte <= 0xFE)
- {
- int ku, ten;
-
- ku = (byte & 0x7F) - 0x20;
- ten = (str[1] & 0x7F) - 0x20;
- if ((ku < 1 || ku > 92) || (ten < 1 || ten > 94))
- {
- *chPtr = (Tcl_UniChar) byte;
- return 1;
- }
+ if (0xA1 <= byte && byte <= 0xFE) {
+ int ku, ten;
+
+ ku = (byte & 0x7F) - 0x20;
+ ten = (str[1] & 0x7F) - 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
+ *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;
+ 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;
}
- /*
- * 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;
+ 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;
}
- ch <<= 6;
- ch |= (*str & 0x3F);
- trail--;
- }
- while (trail > 0);
- *chPtr = ch;
- return total;
}
- }
#endif
- *chPtr = (Tcl_UniChar) byte;
- return 1;
+ *chPtr = (Tcl_UniChar) byte;
+ return 1;
}
/********************************************************************/
/* font cache functions */
-static int
-fontTest (void *element, void *key)
+static int fontTest (void *element, void *key)
{
- font_t *a = (font_t *) element;
- fontkey_t *b = (fontkey_t *) key;
+ font_t *a = (font_t *) element;
+ fontkey_t *b = (fontkey_t *) key;
- return (strcmp (a->fontlist, b->fontlist) == 0);
+ return (strcmp (a->fontlist, b->fontlist) == 0);
}
static void *fontFetch (char **error, void *key)
fontsearchpath = getenv ("GDFONTPATH");
if (!fontsearchpath) {
fontsearchpath = DEFAULT_FONTPATH;
- }
+ }
fontlist = gdEstrdup(a->fontlist);
/*
/* make a fresh copy each time - strtok corrupts it. */
path = gdEstrdup (fontsearchpath);
- /* if name is an absolute filename then test directly */
+ /* if name is an absolute filename then test directly */
if (*name == '/' || (name[0] != 0 && name[1] == ':' && (name[2] == '/' || name[2] == '\\'))) {
snprintf(fullname, sizeof(fullname) - 1, "%s", name);
if (access(fullname, R_OK) == 0) {
path = NULL;
if (font_found) {
break;
- }
+ }
}
-
+
if (path) {
gdFree(path);
}
-
+
gdFree(fontlist);
-
+
if (!font_found) {
gdPFree(a->fontlist);
gdPFree(a);
* does the work so that text can be alpha blended across a complex
* background (TBB; and for real in 2.0.2).
*/
-static void *
-tweenColorFetch (char **error, void *key)
+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)
- {
- if ((pixel + pixel) >= NUMCOLORS)
- a->tweencolor = -fg;
- else
- a->tweencolor = bg;
- }
- else
- {
- npixel = NUMCOLORS - pixel;
- if (im->trueColor)
- {
- /* 2.0.1: use gdImageSetPixel to do the alpha blending work,
- or to just store the alpha level. All we have to do here
- is incorporate our knowledge of the percentage of this
- pixel that is really "lit" by pushing the alpha value
- up toward transparency in edge regions. */
- a->tweencolor = gdTrueColorAlpha (
- gdTrueColorGetRed (fg),
- gdTrueColorGetGreen (fg),
- gdTrueColorGetBlue (fg),
- gdAlphaMax - (gdTrueColorGetAlpha (fg) * pixel / NUMCOLORS));
- }
- else
- {
- 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;
+ 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) {
+ if ((pixel + pixel) >= NUMCOLORS) {
+ a->tweencolor = -fg;
+ } else {
+ a->tweencolor = bg;
+ }
+ } else {
+ npixel = NUMCOLORS - pixel;
+ if (im->trueColor) {
+ /* 2.0.1: use gdImageSetPixel to do the alpha blending work,
+ * or to just store the alpha level. All we have to do here
+ * is incorporate our knowledge of the percentage of this
+ * pixel that is really "lit" by pushing the alpha value
+ * up toward transparency in edge regions.
+ */
+ a->tweencolor = gdTrueColorAlpha(
+ gdTrueColorGetRed(fg),
+ gdTrueColorGetGreen(fg),
+ gdTrueColorGetBlue(fg),
+ gdAlphaMax - (gdTrueColorGetAlpha (fg) * pixel / NUMCOLORS));
+ } else {
+ 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)
+static void tweenColorRelease (void *element)
{
- gdFree ((char *) element);
+ gdFree((char *) element);
}
/* draw_bitmap - transfers glyph bitmap to GD image */
-static char *
-gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, FT_Bitmap bitmap, int pen_x, int pen_y)
+static char * gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, FT_Bitmap bitmap, int pen_x, int pen_y)
{
- unsigned char *pixel = NULL;
- int *tpixel = NULL;
- int x, y, row, col, pc, pcr;
-
- tweencolor_t *tc_elem;
- tweencolorkey_t tc_key;
-
- /* copy to image, mapping colors */
- tc_key.fgcolor = fg;
- tc_key.im = im;
- /* Truecolor version; does not require the cache */
- if (im->trueColor)
- {
- for (row = 0; row < bitmap.rows; row++)
- {
- pc = row * bitmap.pitch;
- pcr = pc;
- y = pen_y + row;
- /* clip if out of bounds */
- /* 2.0.16: clipping rectangle, not image bounds */
- if ((y > im->cy2) || (y < im->cy1))
- continue;
- for (col = 0; col < bitmap.width; col++, pc++)
- {
- int level;
- if (bitmap.pixel_mode == ft_pixel_mode_grays)
- {
- /*
- * Scale to 128 levels of alpha for gd use.
- * alpha 0 is opacity, so be sure to invert at the end
- */
- level = (bitmap.buffer[pc] * gdAlphaMax /
- (bitmap.num_grays - 1));
- }
- else if (bitmap.pixel_mode == ft_pixel_mode_mono)
- {
- /* 2.0.5: mode_mono fix from Giuliano Pochini */
- level = ((bitmap.buffer[(col>>3)+pcr]) & (1<<(~col&0x07)))
- ? gdAlphaTransparent :
- gdAlphaOpaque;
- }
- else
- {
- return "Unsupported ft_pixel_mode";
- }
- if ((fg >= 0) && (im->trueColor)) {
- /* Consider alpha in the foreground color itself to be an
- upper bound on how opaque things get, when truecolor is
- available. Without truecolor this results in far too many
- color indexes. */
- level = level * (gdAlphaMax - gdTrueColorGetAlpha(fg)) / gdAlphaMax;
- }
- level = gdAlphaMax - level;
- x = pen_x + col;
- /* clip if out of bounds */
- /* 2.0.16: clip to clipping rectangle, Matt McNabb */
- if ((x > im->cx2) || (x < im->cx1))
- continue;
- /* get pixel location in gd buffer */
- tpixel = &im->tpixels[y][x];
- if (fg < 0) {
- if (level < (gdAlphaMax / 2)) {
- *tpixel = -fg;
- }
- } else {
- if (im->alphaBlendingFlag) {
- *tpixel = gdAlphaBlend(*tpixel, (level << 24) + (fg & 0xFFFFFF));
- } else {
- *tpixel = (level << 24) + (fg & 0xFFFFFF);
- }
- }
- }
- }
- return (char *) NULL;
- }
- /* Non-truecolor case, restored to its more or less original form */
- for (row = 0; row < bitmap.rows; row++)
- {
- int pcr;
- pc = row * bitmap.pitch;
- pcr = pc;
- if(bitmap.pixel_mode==ft_pixel_mode_mono)
- pc *= 8; /* pc is measured in bits for monochrome images */
-
- 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;
- /* 2.0.5: mode_mono fix from Giuliano Pochini */
- tc_key.pixel = ((bitmap.buffer[(col>>3)+pcr]) & (1<<(~col&0x07)))
- ? 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. gd 2.0.2: watch out for
- negative indexes (thanks to David Marwood). */
- *pixel = (fg < 0) ? -fg : fg;
+ unsigned char *pixel = NULL;
+ int *tpixel = NULL;
+ int x, y, row, col, pc, pcr;
+
+ tweencolor_t *tc_elem;
+ tweencolorkey_t tc_key;
+
+ /* copy to image, mapping colors */
+ tc_key.fgcolor = fg;
+ tc_key.im = im;
+ /* Truecolor version; does not require the cache */
+ if (im->trueColor) {
+ for (row = 0; row < bitmap.rows; row++) {
+ pc = row * bitmap.pitch;
+ pcr = pc;
+ y = pen_y + row;
+ /* clip if out of bounds */
+ /* 2.0.16: clipping rectangle, not image bounds */
+ if ((y > im->cy2) || (y < im->cy1)) {
+ continue;
+ }
+ for (col = 0; col < bitmap.width; col++, pc++) {
+ int level;
+ if (bitmap.pixel_mode == ft_pixel_mode_grays) {
+ /* Scale to 128 levels of alpha for gd use.
+ * alpha 0 is opacity, so be sure to invert at the end
+ */
+ level = (bitmap.buffer[pc] * gdAlphaMax / (bitmap.num_grays - 1));
+ } else if (bitmap.pixel_mode == ft_pixel_mode_mono) {
+ /* 2.0.5: mode_mono fix from Giuliano Pochini */
+ level = ((bitmap.buffer[(col>>3)+pcr]) & (1<<(~col&0x07))) ? gdAlphaTransparent : gdAlphaOpaque;
+ } else {
+ return "Unsupported ft_pixel_mode";
+ }
+ if ((fg >= 0) && (im->trueColor)) {
+ /* Consider alpha in the foreground color itself to be an
+ * upper bound on how opaque things get, when truecolor is
+ * available. Without truecolor this results in far too many
+ * color indexes.
+ */
+ level = level * (gdAlphaMax - gdTrueColorGetAlpha(fg)) / gdAlphaMax;
+ }
+ level = gdAlphaMax - level;
+ x = pen_x + col;
+ /* clip if out of bounds */
+ /* 2.0.16: clip to clipping rectangle, Matt McNabb */
+ if ((x > im->cx2) || (x < im->cx1)) {
+ continue;
+ }
+ /* get pixel location in gd buffer */
+ tpixel = &im->tpixels[y][x];
+ if (fg < 0) {
+ if (level < (gdAlphaMax / 2)) {
+ *tpixel = -fg;
+ }
+ } else {
+ if (im->alphaBlendingFlag) {
+ *tpixel = gdAlphaBlend(*tpixel, (level << 24) + (fg & 0xFFFFFF));
+ } else {
+ *tpixel = (level << 24) + (fg & 0xFFFFFF);
+ }
+ }
+ }
}
- else
- {
- /* find antialised color */
-
- tc_key.bgcolor = *pixel;
- tc_elem = (tweencolor_t *) gdCacheGet (
- tc_cache, &tc_key);
- *pixel = tc_elem->tweencolor;
+ return (char *) NULL;
+ }
+ /* Non-truecolor case, restored to its more or less original form */
+ for (row = 0; row < bitmap.rows; row++) {
+ int pcr;
+ pc = row * bitmap.pitch;
+ pcr = pc;
+ if (bitmap.pixel_mode==ft_pixel_mode_mono) {
+ pc *= 8; /* pc is measured in bits for monochrome images */
+ }
+ 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;
+ /* 2.0.5: mode_mono fix from Giuliano Pochini */
+ tc_key.pixel = ((bitmap.buffer[(col>>3)+pcr]) & (1<<(~col&0x07))) ? 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. gd 2.0.2: watch out for
+ * negative indexes (thanks to David Marwood).
+ */
+ *pixel = (fg < 0) ? -fg : 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;
+ return (char *) NULL;
}
static int
gdroundupdown (FT_F26Dot6 v1, int updown)
{
- return (!updown)
- ? (v1 < 0 ? ((v1 - 63) >> 6) : v1 >> 6)
- : (v1 > 0 ? ((v1 + 63) >> 6) : v1 >> 6);
+ return (!updown) ? (v1 < 0 ? ((v1 - 63) >> 6) : v1 >> 6) : (v1 > 0 ? ((v1 + 63) >> 6) : v1 >> 6);
}
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,
+gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
double ptsize, double angle, int x, int y, char *string)
{
return gdImageStringFTEx(im, brect, fg, fontlist, ptsize, angle, x, y, string, 0);
}
}
/*****/
-
+
gdMutexLock(gdFontCacheMutex);
/* get the font (via font cache) */
fontkey.fontlist = fontlist;
next += len;
}
break;
- case gdFTEX_Shift_JIS:
+ case gdFTEX_Shift_JIS:
if (font->have_char_map_sjis) {
unsigned char c;
int jiscode;
-#ifndef GDHELPERS_H
+#ifndef GDHELPERS_H
#define GDHELPERS_H 1
#include <sys/types.h>
va_list args;
char *tmp;
TSRMLS_FETCH();
-
+
va_start(args, format);
vspprintf(&tmp, 0, format, args);
va_end(args);
-/*
+/*
add ability to load xpm files to gd, requires the xpm
library.
- Caolan.McNamara@ul.ie
+ Caolan.McNamara@ul.ie
http://www.csn.ul.ie/~caolan
*/
#include <stdio.h>
}
/* Load original PNG, which should contain alpha channel
information. We will use it in two ways: preserving it
- literally, for use with compatible browsers, and
+ literally, for use with compatible browsers, and
compositing it ourselves against a background of our
choosing (alpha blending). We'll change its size
and try creating palette versions of it. */
/* Create output image. */
im_out = gdImageCreateTrueColor ((int) (gdImageSX (im_in) * scale),
(int) (gdImageSY (im_in) * scale));
- /*
+ /*
Request alpha blending. This causes future
drawing operations to perform alpha channel blending
with the background, resulting in an opaque image.
/* If this image is the result of alpha channel blending,
it will not contain an interesting alpha channel itself.
- Save a little file size by not saving the alpha channel.
+ Save a little file size by not saving the alpha channel.
Otherwise the file would typically be slightly larger. */
gdImageSaveAlpha (im_out, !blending);
/* getmbi
** ------
- ** Get a multibyte integer from a generic getin function
+ ** Get a multibyte integer from a generic getin function
** 'getin' can be getc, with in = NULL
** you can find getin as a function just above the main function
** This way you gain a lot of flexibilty about how this package
** Why not just giving a filedescriptor to this function?
** Well, the incentive to write this function was the complete
** integration in gd library from www.boutell.com. They use
- ** their own io functions, so the passing of a function seemed to be
+ ** their own io functions, so the passing of a function seemed to be
** a logic(?) decision ...
**
*/
return (putc (c, (FILE *) out));
}
-/* getin from file descriptor
+/* getin from file descriptor
** --------------------------
*/
int
** (c) 2000 Johan Van den Brande <johan@vandenbrande.com>
**
** Header file
-*/
+*/
#ifndef __WBMP_H
#define __WBMP_H 1
** A Wireless bitmap structure
**
*/
-
+
typedef struct Wbmp_
{
int type; /* type of the wbmp */
int height; /* height of the image */
int *bitmap; /* pointer to data: 0 = WHITE , 1 = BLACK */
} Wbmp;
-
+
#define WBMP_WHITE 1
#define WBMP_BLACK 0
-
+
/* Proto's
** -------
**
*/
-void putmbi( int i, void (*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, void (*putout)( int c, void *out), void *out);
void freewbmp( Wbmp *wbmp );
-void printwbmp( Wbmp *wbmp );
+void printwbmp( Wbmp *wbmp );
#endif
maxy = gdImageSY(im);
printf("alpha channel information:\n");
-
+
if (im->trueColor) {
for (y = 0; y < maxy; y++) {
for (x = 0; x < maxx; x++) {
}
else
printf("NOT a true color image\n");
- no = 0;
+ no = 0;
printf("%d alpha channels\n", nalpha);
-
+
}
else
{
int ch;
char h[8];
unsigned int b;
-
+
rewind(fd);
while (fgets(fline, MAX_XBM_LINE_SIZE, fd)) {
fline[MAX_XBM_LINE_SIZE-1] = '\0';
} else {
type++;
}
-
+
if (!strcmp("width", type)) {
width = (unsigned int) value;
}
char *buf;
int len;
va_list args;
-
+
va_start(args, format);
len = vspprintf(&buf, 0, format, args);
va_end(args);