13#define __attribute__(any)
20#define ASC(ch) gd_toascii[(unsigned char)ch]
21static const unsigned char gd_toascii[256] =
23 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
24 0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
25 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
26 0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f,
27 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
28 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07,
29 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
30 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a,
31 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
32 0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c,
33 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
34 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f,
35 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
36 0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f,
38 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
39 0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22,
40 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
41 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1,
42 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
43 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4,
44 0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
45 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae,
46 0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
47 0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7,
48 0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
49 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5,
50 0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
51 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff,
52 0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
53 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5,
54 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
55 0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e
60#define floor_cast(exp) ((long) exp)
73 fputs(
"GD Error: ", stderr);
76 fputs(
"GD Warning: ", stderr);
79 fputs(
"GD Notice: ", stderr);
83 fputs(
"GD Info: ", stderr);
86 fputs(
"GD Debug: ", stderr);
96static void _gd_error_ex(
int priority,
const char *format, va_list
args)
98 if (gd_error_method) {
99 gd_error_method(priority, format,
args);
107 va_start(
args, format);
115 va_start(
args, format);
116 _gd_error_ex(priority, format,
args);
125 gd_error_method = error_method;
136static void gdImageBrushApply(
gdImagePtr im,
int x,
int y);
137static void gdImageTileApply(
gdImagePtr im,
int x,
int y);
138static int gdAlphaOverlayColor(
int src,
int dst,
int max);
149 if (
overflow2(
sizeof(
unsigned char *), sy)) {
152 if (
overflow2(
sizeof(
unsigned char), sx)) {
159 im->
pixels = (
unsigned char **)
gdMalloc(
sizeof(
unsigned char *) * sy);
165 for (i = 0; i < sy; i++) {
167 im->
pixels[i] = (
unsigned char *)
gdCalloc(sx,
sizeof(
unsigned char));
186 im->
cx2 = im->
sx - 1;
187 im->
cy2 = im->
sy - 1;
218 for (i = 0; i < sy; i++) {
238 im->
cx2 = im->
sx - 1;
239 im->
cy2 = im->
sy - 1;
251 for (i = 0; i < im->
sy; i++) {
257 for (i = 0; i < im->
sy; i++) {
293 gd = im->
green[i] - g;
294 bd = im->
blue[i] - b;
297 dist = rd * rd + gd * gd + bd * bd + ad * ad;
298 if (first || (dist < mindist)) {
312#define RETURN_HWB(h, w, b) {HWB->H = h; HWB->W = w; HWB->B = b; return HWB;}
313#define RETURN_RGB(r, g, b) {RGB->R = r; RGB->G = g; RGB->B = b; return RGB;}
314#define HWB_UNDEFINED -1
315#define SETUP_RGB(s, r, g, b) {s.R = r/255.0f; s.G = g/255.0f; s.B = b/255.0f;}
318#define MIN(a,b) ((a)<(b)?(a):(b))
320#define MIN3(a,b,c) ((a)<(b)?(MIN(a,c)):(MIN(b,c)))
322#define MAX(a,b) ((a)<(b)?(b):(a))
324#define MAX3(a,b,c) ((a)<(b)?(MAX(b,c)):(MAX(a,c)))
350 float R = RGB.
R,
G = RGB.
G,
B = RGB.
B, w,
v, b, f;
359 f = (
R == w) ?
G -
B : ((
G == w) ?
B -
R :
R -
G);
360 i = (
R == w) ? 3 : ((
G == w) ? 5 : 1);
365static float HWB_Diff (
int r1,
int g1,
int b1,
int r2,
int g2,
int b2)
374 RGB_to_HWB(RGB1, &HWB1);
375 RGB_to_HWB(RGB2, &HWB2);
385 diff = fabsf(HWB1.
H - HWB2.
H);
391 diff = diff * diff + (HWB1.
W - HWB2.
W) * (HWB1.
W - HWB2.
W) + (HWB1.
B - HWB2.
B) * (HWB1.
B - HWB2.
B);
409 float h = HWB.
H, w = HWB.
W, b = HWB.
B,
v,
n, f;
457 dist = HWB_Diff(im->
red[i], im->
green[i], im->
blue[i], r, g, b);
458 if (first || (dist < mindist)) {
482 if ((im->
red[i] == r) && (im->
green[i] == g) && (im->
blue[i] == b) && (im->
alpha[i] ==
a)) {
544 long rd, gd, bd, ad, dist;
545 long mindist = 4 * 255 * 255;
564 rd = (long) (im->
red[c] - r);
565 gd = (long) (im->
green[c] - g);
566 bd = (long) (im->
blue[c] - b);
567 ad = (long) (im->
alpha[c] -
a);
568 dist = rd * rd + gd * gd + bd * bd + ad * ad;
633 for (i = 0; i < 256; i++) {
637 for (y = 0; y < to->
sy; y++) {
638 for (x = 0; x < to->
sx; x++) {
640 if (xlate[
p] == -1) {
649 to->
red[i] = from->
red[i];
656 for (i = from->
colorsTotal; i < to->colorsTotal; i++) {
684static int clip_1d(
int *x0,
int *y0,
int *x1,
int *y1,
int maxdim) {
691 m = (*y1 - *y0)/(
double)(*x1 - *x0);
693 *y0 -= (int)(m * *x0);
697 *y1 += (int)(m * (maxdim - *x1));
706 m = (*y1 - *y0)/(
double)(*x1 - *x0);
707 *y0 += (int)(m * (maxdim - *x0));
711 *y1 -= (int)(m * *x1);
718 m = (*y1 - *y0)/(
double)(*x1 - *x0);
719 *y1 += (int)(m * (maxdim - *x1));
724 m = (*y1 - *y0)/(
double)(*x1 - *x0);
725 *y1 -= (int)(m * *x1);
761 gdImageBrushApply(im, x, y);
764 gdImageTileApply(im, x, y);
809static void gdImageBrushApply (
gdImagePtr im,
int x,
int y)
830 for (ly = y1; ly < y2; ly++) {
832 for (lx = x1; (lx < x2); lx++) {
845 for (ly = y1; ly < y2; ly++) {
847 for (lx = x1; lx < x2; lx++) {
861 for (ly = y1; ly < y2; ly++) {
863 for (lx = x1; lx < x2; lx++) {
885static void gdImageTileApply (
gdImagePtr im,
int x,
int y)
922static int gdImageTileGet (
gdImagePtr im,
int x,
int y)
971static void _gdImageFilledHRectangle (
gdImagePtr im,
int x1,
int y1,
int x2,
int y2,
int color);
990 dst->
red[i] = src->
red[i];
996 for (i = 0; i < src->
sy; i++) {
997 for (x = 0; x < src->
sx; x++) {
1002 for (i = 0; i < src->
sy; i++) {
1003 for (x = 0; x < src->
sx; x++) {
1057static void gdImageHLine(
gdImagePtr im,
int y,
int x1,
int x2,
int col)
1059 if (im->
thick > 1) {
1060 int thickhalf = im->
thick >> 1;
1061 _gdImageFilledHRectangle(im, x1, y - thickhalf, x2, y + im->
thick - thickhalf - 1, col);
1069 for (;x1 <= x2; x1++) {
1076static void gdImageVLine(
gdImagePtr im,
int x,
int y1,
int y2,
int col)
1078 if (im->
thick > 1) {
1079 int thickhalf = im->
thick >> 1;
1088 for (;y1 <= y2; y1++) {
1098 int dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;
1101 int thick = im->
thick;
1114 if (!clip_1d(&x1,&y1,&x2,&y2,
gdImageSX(im)-1) || !clip_1d(&y1,&x1,&y2,&x2,
gdImageSY(im)-1)) {
1122 gdImageVLine(im, x1, y1, y2,
color);
1124 }
else if (dy == 0) {
1125 gdImageHLine(im, y1, x1, x2,
color);
1132 if ((dx == 0) && (dy == 0)) {
1149 incr2 = 2 * (dy - dx);
1163 wstart = y - wid / 2;
1164 for (w = wstart; w < wstart + wid; w++) {
1168 if (((y2 - y1) * ydirflag) > 0) {
1177 wstart = y - wid / 2;
1178 for (w = wstart; w < wstart + wid; w++) {
1191 wstart = y - wid / 2;
1192 for (w = wstart; w < wstart + wid; w++) {
1213 incr2 = 2 * (dx - dy);
1227 wstart = x - wid / 2;
1228 for (w = wstart; w < wstart + wid; w++) {
1232 if (((x2 - x1) * xdirflag) > 0) {
1241 wstart = x - wid / 2;
1242 for (w = wstart; w < wstart + wid; w++) {
1255 wstart = x - wid / 2;
1256 for (w = wstart; w < wstart + wid; w++) {
1268#define BLEND_COLOR(a, nc, c, cc) \
1269nc = (cc) + (((((c) - (cc)) * (a)) + ((((c) - (cc)) * (a)) >> 8) + 0x80) >> 8);
1271inline static void gdImageSetAAPixelColor(
gdImagePtr im,
int x,
int y,
int color,
int t)
1273 int dr,dg,db,
p,r,g,b;
1295 long x, y, inc, frac;
1305 if (!clip_1d(&x1,&y1,&x2,&y2,
gdImageSX(im)-1) || !clip_1d(&y1,&x1,&y2,&x2,
gdImageSY(im)-1)) {
1312 if (dx == 0 && dy == 0) {
1315 if (
abs((
int)dx) >
abs((
int)dy)) {
1327 inc = (dy * 65536) / dx;
1329 for (x = x1; x <= x2; x++) {
1330 gdImageSetAAPixelColor(im, x, y, col, (frac >> 8) & 0xFF);
1331 if (y + 1 < im->
sy) {
1332 gdImageSetAAPixelColor(im, x, y + 1, col, (~frac >> 8) & 0xFF);
1335 if (frac >= 65536) {
1338 }
else if (frac < 0) {
1355 inc = (dx * 65536) / dy;
1357 for (y = y1; y <= y2; y++) {
1358 gdImageSetAAPixelColor(im, x, y, col, (frac >> 8) & 0xFF);
1359 if (x + 1 < im->
sx) {
1360 gdImageSetAAPixelColor(im, x + 1, y, col, (~frac >> 8) & 0xFF);
1363 if (frac >= 65536) {
1366 }
else if (frac < 0) {
1374static void dashedSet (
gdImagePtr im,
int x,
int y,
int color,
int *onP,
int *dashStepP,
int wid,
int vert);
1378 int dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;
1383 int thick = im->
thick;
1401 incr2 = 2 * (dy - dx);
1413 dashedSet(im, x, y,
color, &on, &dashStep, wid, vert);
1414 if (((y2 - y1) * ydirflag) > 0) {
1423 dashedSet(im, x, y,
color, &on, &dashStep, wid, vert);
1434 dashedSet(im, x, y,
color, &on, &dashStep, wid, vert);
1450 incr2 = 2 * (dx - dy);
1462 dashedSet(im, x, y,
color, &on, &dashStep, wid, vert);
1463 if (((x2 - x1) * xdirflag) > 0) {
1472 dashedSet(im, x, y,
color, &on, &dashStep, wid, vert);
1483 dashedSet(im, x, y,
color, &on, &dashStep, wid, vert);
1489static void dashedSet (
gdImagePtr im,
int x,
int y,
int color,
int *onP,
int *dashStepP,
int wid,
int vert)
1491 int dashStep = *dashStepP;
1502 wstart = y - wid / 2;
1503 for (w = wstart; w < wstart + wid; w++) {
1507 wstart = x - wid / 2;
1508 for (w = wstart; w < wstart + wid; w++) {
1513 *dashStepP = dashStep;
1526#ifdef CHARSET_EBCDIC
1532 fline = (c - f->
offset) * f->
h * f->
w;
1533 for (py = y; py < yuppper; py++) {
1534 for (px = x; px < xuppper; px++) {
1535 if (f->
data[fline + cy * f->
w + cx]) {
1554#ifdef CHARSET_EBCDIC
1560 fline = (c - f->
offset) * f->
h * f->
w;
1561 for (py = y; py > ylower; py--) {
1562 for (px = x; px < xuppper; px++) {
1563 if (f->
data[fline + cy * f->
w + cx]) {
1578 for (i = 0; (i < l); i++) {
1589 for (i = 0; (i < l); i++) {
1595static int strlen16 (
unsigned short *
s);
1602 for (i = 0; (i < l); i++) {
1613 for (i = 0; i < l; i++) {
1619static int strlen16 (
unsigned short *
s)
1656 int startx = -1, starty = -1, endx = -1, endy = -1;
1658 if ((
s % 360) == (e % 360)) {
1681 for (i =
s, pti = 1; i <= e; i++, pti++) {
1683 x = endx = ((long)
gdCosT[i % 360] * (long) w / (2 * 1024)) + cx;
1684 y = endy = ((long)
gdSinT[i % 360] * (long) h / (2 * 1024)) + cy;
1692 if (((i > 270 || i < 90) && x > lx) || ((i > 90 && i < 270) && x < lx)) {
1709 pts[pti].
x = startx = x;
1710 pts[pti].
y = starty = y;
1740 if (pts[1].x != startx && pts[1].y == starty) {
1742 for (i = pti; i > 1; i--) {
1743 pts[i].
x = pts[i-1].
x;
1744 pts[i].
y = pts[i-1].
y;
1750 if (pts[pti-1].x != endx && pts[pti-1].y == endy) {
1773 int x=0,mx1=0,mx2=0,my1=0,my2=0;
1774 int64_t aq,bq,dx,dy,r,rx,ry,
a,b;
1780 mx1 = mx-
a;my1 = my;
1781 mx2 = mx+
a;my2 = my;
1812 int x=0,mx1=0,mx2=0,my1=0,my2=0;
1813 int64_t aq,bq,dx,dy,r,rx,ry,
a,b;
1820 for (x = mx-
a; x <= mx+
a; x++) {
1824 mx1 = mx-
a;my1 = my;
1825 mx2 = mx+
a;my2 = my;
1849 for(i=mx1;i<=mx2;i++){
1862 int leftLimit = -1, rightLimit;
1863 int i, restoreAlphaBlending = 0;
1865 if (border < 0 ||
color < 0) {
1890 for (i = x; i >= 0; i--) {
1897 if (leftLimit == -1) {
1903 for (i = (x + 1); i < im->
sx; i++) {
1914 for (i = leftLimit; i <= rightLimit; i++) {
1917 if ((c != border) && (c !=
color)) {
1921 }
else if ((c == border) || (c ==
color)) {
1928 if (y < ((im->
sy) - 1)) {
1930 for (i = leftLimit; i <= rightLimit; i++) {
1934 if ((c != border) && (c !=
color)) {
1938 }
else if ((c == border) || (c ==
color)) {
1960#define FILL_MAX ((int)(im->sy*im->sx)/4)
1961#define FILL_PUSH(Y, XL, XR, DY) \
1962 if (sp<stack+FILL_MAX && Y+(DY)>=0 && Y+(DY)<wy2) \
1963 {sp->y = Y; sp->xl = XL; sp->xr = XR; sp->dy = DY; sp++;}
1965#define FILL_POP(Y, XL, XR, DY) \
1966 {sp--; Y = sp->y+(DY = sp->dy); XL = sp->xl; XR = sp->xr;}
1968static void _gdImageFillTiled(
gdImagePtr im,
int x,
int y,
int nc);
1976 int alphablending_bak;
1991 _gdImageFillTiled(im,x,
y,nc);
1996 wx2=im->
sx;wy2=im->
sy;
1998 if (oc==nc || x<0 || x>wx2 ||
y<0 || y>wy2) {
2007 int ix = x, iy =
y, c;
2015 }
while(ix++ < (im->
sx -1));
2017 }
while(iy++ < (im->
sy -1));
2066static void _gdImageFillTiled(
gdImagePtr im,
int x,
int y,
int nc)
2068 int i, l, x1, x2,
dy;
2080 wx2=im->
sx;wy2=im->
sy;
2082 nc = gdImageTileGet(im,x,
y);
2084 pts = (
char **)
ecalloc(im->
sy + 1,
sizeof(
char *));
2085 for (i = 0; i < im->
sy + 1; i++) {
2086 pts[i] = (
char *)
ecalloc(im->
sx + 1,
sizeof(
char));
2101 nc = gdImageTileGet(im,x,
y);
2117 nc = gdImageTileGet(im,x,
y);
2132 for(i = 0; i < im->
sy + 1; i++) {
2144 int thick = im->
thick;
2147 if (x1 == x2 && y1 == y2 && thick == 1) {
2165 int cx, cy, x1ul, y1ul, x2lr, y2lr;
2166 int half = thick >> 1;
2175 while (cy-- > y1ul) {
2177 while (cx++ < x2lr) {
2183 while (cy++ < y2lr) {
2185 while (cx++ < x2lr) {
2190 cy = y1ul + thick - 1;
2191 while (cy++ < y2lr -thick) {
2193 while (cx++ < x1ul + thick) {
2198 cy = y1ul + thick - 1;
2199 while (cy++ < y2lr -thick) {
2200 cx = x2lr - thick - 1;
2201 while (cx++ < x2lr) {
2208 if (x1 == x2 || y1 == y2) {
2219static void _gdImageFilledHRectangle (
gdImagePtr im,
int x1,
int y1,
int x2,
int y2,
int color)
2223 if (x1 == x2 && y1 == y2) {
2256 for (x = x1; (x <= x2); x++) {
2257 for (
y = y1; (
y <= y2);
y++) {
2263static void _gdImageFilledVRectangle (
gdImagePtr im,
int x1,
int y1,
int x2,
int y2,
int color)
2267 if (x1 == x2 && y1 == y2) {
2300 for (
y = y1; (
y <= y2);
y++) {
2301 for (x = x1; (x <= x2); x++) {
2309 _gdImageFilledVRectangle(im, x1, y1, x2, y2,
color);
2327 for (
y = 0; (
y < h);
y++) {
2328 for (x = 0; (x < w); x++) {
2337 for (
y = 0; (
y < h);
y++) {
2338 for (x = 0; (x < w); x++) {
2354 for (
y = srcY;
y < (srcY + h);
y++) {
2356 for (x = srcX; x < (srcX + w); x++) {
2371 }
else if (colorMap[c] == (-1)) {
2380 mapTo = colorMap[c];
2382 mapTo = colorMap[c];
2401 for (
y = srcY;
y < (srcY + h);
y++) {
2403 for (x = srcX; x < (srcX + w); x++) {
2417 ncR = (int)(
gdImageRed (src, c) * (pct / 100.0) +
gdImageRed (dst, dc) * ((100 - pct) / 100.0));
2442 for (
y = srcY; (
y < (srcY + h));
y++) {
2444 for (x = srcX; (x < (srcX + w)); x++) {
2458 if (dst == src && pct == 100) {
2464 ncR = (int)(
gdImageRed (src, c) * (pct / 100.0f) + g * ((100 - pct) / 100.0));
2465 ncG = (int)(
gdImageGreen (src, c) * (pct / 100.0f) + g * ((100 - pct) / 100.0));
2466 ncB = (int)(
gdImageBlue (src, c) * (pct / 100.0f) + g * ((100 - pct) / 100.0));
2505 stx = (
int *)
gdMalloc (
sizeof (
int) * srcW);
2506 sty = (
int *)
gdMalloc (
sizeof (
int) * srcH);
2509 for (i = 0; (i < srcW); i++) {
2510 stx[i] = dstW * (i+1) / srcW - dstW * i / srcW ;
2512 for (i = 0; (i < srcH); i++) {
2513 sty[i] = dstH * (i+1) / srcH - dstH * i / srcH ;
2519 for (
y = srcY; (
y < (srcY + srcH));
y++) {
2520 for (ydest = 0; (ydest < sty[
y - srcY]); ydest++) {
2522 for (x = srcX; (x < (srcX + srcW)); x++) {
2525 if (!stx[x - srcX]) {
2535 tox += stx[x - srcX];
2544 tox += stx[x - srcX];
2552 tox += stx[x - srcX];
2563 if (colorMap[c] == (-1)) {
2577 mapTo = colorMap[c];
2580 for (i = 0; (i < stx[x - srcX]); i++) {
2600 double sy1, sy2, sx1, sx2;
2606 for (
y = dstY; (
y < dstY + dstH);
y++) {
2607 sy1 = ((double)
y - (double) dstY) * (
double) srcH / (double) dstH;
2608 sy2 = ((double) (
y + 1) - (double) dstY) * (
double) srcH / (double) dstH;
2609 for (x = dstX; (x < dstX + dstW); x++) {
2612 double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
2613 double alpha_factor, alpha_sum = 0.0, contrib_sum = 0.0;
2614 sx1 = ((double) x - (double) dstX) * (
double) srcW / dstW;
2615 sx2 = ((double) (x + 1) - (double) dstX) * (
double) srcW / dstW;
2621 if (yportion > sy2 - sy1) {
2622 yportion = sy2 - sy1;
2625 }
else if (sy == floorf(sy2)) {
2633 double pcontribution;
2637 if (xportion > sx2 - sx1) {
2638 xportion = sx2 - sx1;
2641 }
else if (sx == floorf(sx2)) {
2646 pcontribution = xportion * yportion;
2654 alpha_sum += alpha_factor;
2655 contrib_sum += pcontribution;
2656 spixels += xportion * yportion;
2666 if (spixels != 0.0f) {
2672 if ( alpha_sum != 0.0f) {
2673 if( contrib_sum != 0.0f) {
2674 alpha_sum /= contrib_sum;
2681 red = red >= 255.5 ? 255 : red+0.5;
2682 blue = blue >= 255.5 ? 255 : blue+0.5;
2683 green = green >= 255.5 ? 255 : green+0.5;
2712 for (i = 1; i <
n; i++) {
2734 int miny, maxy, pmaxy;
2770 for (i = 1; i <
n; i++) {
2771 if (
p[i].
y < miny) {
2774 if (
p[i].
y > maxy) {
2779 if (
n > 1 && miny == maxy) {
2781 for (i = 1; (i <
n); i++) {
2784 }
else if (
p[i].x > x2) {
2801 for (
y = miny;
y <= maxy;
y++) {
2806 for (i = 0; i <
n; i++) {
2819 }
else if (y1 > y2) {
2831 if (
y >= y1 &&
y < y2) {
2832 im->
polyInts[ints++] = (float) ((
y - y1) * (x2 - x1)) / (float) (y2 - y1) + 0.5 + x1;
2833 }
else if (
y == pmaxy &&
y == y2) {
2839 for (i = 0; i < ints - 1; i += 2) {
2852 return (*(
const int *)
a) - (*(
const int *) b);
2860 if (
overflow2(
sizeof (
int), noOfPixels)) {
2864 memcpy(im->
style, style,
sizeof(
int) * noOfPixels);
2871 im->
thick = thickness;
2940 if (im1->
sx != im2->
sx) {
2942 if (im2->
sx < im1->
sx) {
2948 if (im1->
sy != im2->
sy) {
2950 if (im2->
sy < im1->
sy) {
2959 for (
y = 0;
y < sy;
y++) {
2960 for (x = 0; x < sx; x++) {
2994 int dst_alpha, alpha, red, green, blue;
2995 int src_weight, dst_weight, tot_weight;
3016 tot_weight = src_weight + dst_weight;
3033 return ((alpha << 24) + (red << 16) + (green << 8) + blue);
3059static int gdAlphaOverlayColor (
int src,
int dst,
int max )
3073 return dst + (src << 1) - (dst * src /
max) -
max;
3076 return dst * src /
max;
3082 int a1, a2, r1, r2, g1, g2, b1, b2;
3144 if (res_x > 0) im->
res_x = res_x;
3145 if (res_y > 0) im->
res_y = res_y;
3174 for (
y = 0;
y < sy;
y++) {
3175 const unsigned char *src_row = src->
pixels[
y];
3181 goto clean_on_error;
3185 for (x = 0; x < sx; x++) {
3186 const unsigned char c = *(src_row + x);
3197 for (yy = 0; yy <
y; yy++) {
3215 for (yy = 0; yy <
y; yy++) {
atan2(float $y, float $x)
vfprintf($stream, string $format, array $values)
fputs($stream, string $data, ?int $length=null)
memset(ptr, 0, type->size)
int overflow2(int a, int b)
#define gdImageBlue(im, c)
#define gdTrueColorGetBlue(c)
#define gdAlphaTransparent
#define gdTrueColorGetGreen(c)
#define gdImageTrueColorPixel(im, x, y)
#define gdEffectAlphaBlend
#define gdTrueColorGetAlpha(c)
#define gdImageGetTransparent(im)
#define gdImagePalettePixel(im, x, y)
void(* gdErrorMethod)(int, const char *, va_list)
#define gdTrueColorGetRed(c)
#define GD_CMP_NUM_COLORS
#define gdImageColorsTotal(im)
#define GD_CMP_TRANSPARENT
#define gdTrueColorAlpha(r, g, b, a)
#define gdImageGreen(im, c)
struct gdImageStruct gdImage
struct gdPoint * gdPointPtr
#define gdTrueColor(r, g, b)
#define gdImageAlpha(im, c)
#define gdImageBoundsSafe(im, x, y)
#define gdImageRed(im, c)
#define gdRealloc(ptr, size)
#define gdCalloc(nmemb, size)
#define R(tables, key, h, i, t, l, r)
void gdImageSetTile(gdImagePtr im, gdImagePtr tile)
void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c)
void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color)
void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH)
int gdImageColorAllocateAlpha(gdImagePtr im, int r, int g, int b, int a)
gdImagePtr gdImageCreate(int sx, int sy)
void gdImageAlphaBlending(gdImagePtr im, int alphaBlendingArg)
gdImagePtr gdImageClone(gdImagePtr src)
void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color)
void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color)
void gdImageSetBrush(gdImagePtr im, gdImagePtr brush)
void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color)
void gdImageFilledArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style)
void gdImageColorDeallocate(gdImagePtr im, int color)
void gdImageCharUp(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color)
int gdImageColorResolveAlpha(gdImagePtr im, int r, int g, int b, int a)
int gdImageGetTrueColorPixel(gdImagePtr im, int x, int y)
int gdLayerOverlay(int dst, int src)
void gdImageOpenPolygon(gdImagePtr im, gdPointPtr p, int n, int c)
void gdImageStringUp16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color)
int gdImageGetPixel(gdImagePtr im, int x, int y)
#define FILL_POP(Y, XL, XR, DY)
void gdImageSetAntiAliased(gdImagePtr im, int c)
void gdImageDestroy(gdImagePtr im)
void gdImageSetClip(gdImagePtr im, int x1, int y1, int x2, int y2)
#define RETURN_HWB(h, w, b)
void gdImageSetAntiAliasedDontBlend(gdImagePtr im, int c, int dont_blend)
void gd_error(const char *format,...)
#define FILL_PUSH(Y, XL, XR, DY)
void gdSetErrorMethod(gdErrorMethod error_method)
void gdImageFilledEllipse(gdImagePtr im, int mx, int my, int w, int h, int c)
void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color)
int gdImageColorExact(gdImagePtr im, int r, int g, int b)
void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color)
void gdImageSetThickness(gdImagePtr im, int thickness)
int gdImageColorClosest(gdImagePtr im, int r, int g, int b)
int gdAlphaBlend(int dst, int src)
void gdImageGetClip(gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P)
void gdImageSetResolution(gdImagePtr im, const unsigned int res_x, const unsigned int res_y)
void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c)
void gdImageEllipse(gdImagePtr im, int mx, int my, int w, int h, int c)
void gdImageAALine(gdImagePtr im, int x1, int y1, int x2, int y2, int col)
void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color)
void gdImageCopyResampled(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH)
int gdImageColorExactAlpha(gdImagePtr im, int r, int g, int b, int a)
#define BLEND_COLOR(a, nc, c, cc)
void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels)
int gdImageColorResolve(gdImagePtr im, int r, int g, int b)
int gdCompareInt(const void *a, const void *b)
void gdClearErrorMethod(void)
int gdImagePaletteToTrueColor(gdImagePtr src)
void gd_error_ex(int priority, const char *format,...)
void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color)
int gdImageColorAllocate(gdImagePtr im, int r, int g, int b)
void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
int gdLayerMultiply(int dst, int src)
void gdImageCopyMergeGray(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
void gdImageFill(gdImagePtr im, int x, int y, int nc)
void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h)
void gdImageString16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color)
void gdImagePaletteCopy(gdImagePtr to, gdImagePtr from)
#define RETURN_RGB(r, g, b)
#define SETUP_RGB(s, r, g, b)
void gdImageInterlace(gdImagePtr im, int interlaceArg)
gdImagePtr gdImageCreateTrueColor(int sx, int sy)
void gdImageAABlend(gdImagePtr im)
int gdImageColorClosestAlpha(gdImagePtr im, int r, int g, int b, int a)
void gdImageColorTransparent(gdImagePtr im, int color)
void gd_stderr_error(int priority, const char *format, va_list args)
void gdImageChar(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color)
void gdImageSetPixel(gdImagePtr im, int x, int y, int color)
int gdImageColorClosestHWB(gdImagePtr im, int r, int g, int b)
int gdImageCompare(gdImagePtr im1, gdImagePtr im2)
void gdImageSaveAlpha(gdImagePtr im, int saveAlphaArg)
struct gdImageStruct * brush
int tileColorMap[gdMaxColors]
interpolation_method interpolation
struct gdImageStruct * tile
gdInterpolationMethod interpolation_id
int brushColorMap[gdMaxColors]
#define ecalloc(nmemb, size)
#define safe_emalloc(nmemb, size, offset)
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)