static void gdImageBrushApply(gdImagePtr im, int x, int y);
static void gdImageTileApply(gdImagePtr im, int x, int y);
-static void gdImageAntiAliasedApply(gdImagePtr im, int x, int y);
static int gdLayerOverlay(int dst, int src);
static int gdAlphaOverlayColor(int src, int dst, int max);
int gdImageGetTrueColorPixel(gdImagePtr im, int x, int y);
/* Row-major ever since gd 1.3 */
im->pixels = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy);
- im->AA_opacity = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy);
im->polyInts = 0;
im->polyAllocated = 0;
im->brush = 0;
for (i = 0; i < sy; i++) {
/* Row-major ever since gd 1.3 */
im->pixels[i] = (unsigned char *) gdCalloc(sx, sizeof(unsigned char));
- im->AA_opacity[i] = (unsigned char *) gdCalloc(sx, sizeof(unsigned char));
}
im->sx = sx;
im->sy = sy;
im->interlace = 0;
im->thick = 1;
im->AA = 0;
- im->AA_polygon = 0;
for (i = 0; i < gdMaxColors; i++) {
im->open[i] = 1;
im->red[i] = 0;
im = (gdImage *) gdMalloc(sizeof(gdImage));
memset(im, 0, sizeof(gdImage));
im->tpixels = (int **) gdMalloc(sizeof(int *) * sy);
- im->AA_opacity = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy);
im->polyInts = 0;
im->polyAllocated = 0;
im->brush = 0;
im->style = 0;
for (i = 0; i < sy; i++) {
im->tpixels[i] = (int *) gdCalloc(sx, sizeof(int));
- im->AA_opacity[i] = (unsigned char *) gdCalloc(sx, sizeof(unsigned char));
}
im->sx = sx;
im->sy = sy;
im->alphaBlendingFlag = 1;
im->thick = 1;
im->AA = 0;
- im->AA_polygon = 0;
im->cx1 = 0;
im->cy1 = 0;
im->cx2 = im->sx - 1;
}
gdFree(im->tpixels);
}
- if (im->AA_opacity) {
- for (i = 0; i < im->sy; i++) {
- gdFree(im->AA_opacity[i]);
- }
- gdFree(im->AA_opacity);
- }
if (im->polyInts) {
gdFree(im->polyInts);
}
gdImageTileApply(im, x, y);
break;
case gdAntiAliased:
- gdImageAntiAliasedApply(im, x, y);
+ /* This shouldn't happen (2.0.26) because we just call
+ gdImageAALine now, but do something sane. */
+ gdImageSetPixel(im, x, y, im->AA_color);
break;
default:
if (gdImageBoundsSafe(im, x, y)) {
}
-static void gdImageAntiAliasedApply (gdImagePtr im, int px, int py)
-{
- float p_dist, p_alpha;
- unsigned char opacity;
-
- /*
- * 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 LAC_2, LBC_2;
-
- int Ax_Cx = im->AAL_x1 - px;
- int Ay_Cy = im->AAL_y1 - py;
-
- int Bx_Cx = im->AAL_x2 - px;
- 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.
- * 2.0.14: typo fixed. 2.0.15: moved down below declarations
- * to satisfy non-C++ compilers.
- */
- if (!gdImageBoundsSafe(im, px, py)) {
- return;
- }
-
- /* Get the squares of the lengths of the segemnts AC and BC. */
- LAC_2 = (Ax_Cx * Ax_Cx) + (Ay_Cy * Ay_Cy);
- 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
- * 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
- * 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.
- */
- p_dist = -1;
- }
-
- if ((p_dist >= 0) && (p_dist <= (float) (im->thick))) {
- p_alpha = pow (1.0 - (p_dist / 1.5), 2);
-
- if (p_alpha > 0) {
- if (p_alpha >= 1) {
- opacity = 255;
- } else {
- opacity = (unsigned char) (p_alpha * 255.0);
- }
- if (!im->AA_polygon || (im->AA_opacity[py][px] < opacity)) {
- im->AA_opacity[py][px] = opacity;
- }
- }
- }
-}
-
-
int gdImageGetPixel (gdImagePtr im, int x, int y)
{
if (gdImageBoundsSafe(im, x, y)) {
return;
}
- /* Let it be known that we are drawing a polygon so that the opacity
- * mask doesn't get cleared after each line.
- */
- if (c == gdAntiAliased) {
- im->AA_polygon = 1;
- }
-
if ( im->antialias) {
draw_line = gdImageAALine;
} else {
lx = p->x;
ly = p->y;
}
-
- if (c == gdAntiAliased) {
- im->AA_polygon = 0;
- }
}
int gdCompareInt (const void *a, const void *b);