On Fri, Jan 18, 2008 at 03:06:44PM +0000, Andrew Ross wrote:
>
> To follow up my own response - it is not a fundamental libgd problem. I
> have a simple test case (attached) which does what I would expect. To
> compile this use "gcc test_alpha.c -lgd -o test_alpha".
>
> I can't currently see how this differs from what happens in the gd
> driver.
>
> I have found the cause of the dark lines though (at least for the gd
> driver). If two plotted polygons overlap, as happens in this case, then
> you get a contribution to the colour from both of them. This results
> in the border being a darker shade of red than the interior of the
> polygon. This could be tricky to fix.
Sorry - forgot the attachment. Try again.
Andrew
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include "gd.h"
int
main (void)
{
/* Input and output files */
FILE *in;
FILE *out;
/* Input and output images */
gdImagePtr im_in = 0, im_out = 0;
/* Brush image */
gdImagePtr brush;
/* Color indexes */
int white;
int blue;
int red;
int green;
/* Points for polygon */
gdPoint points[4];
int i;
int y;
/* Create output image, in true color. */
im_out = gdImageCreateTrueColor (256 + 384, 384);
/* 2.0.2: first color allocated would automatically be background in a
palette based image. Since this is a truecolor image, with an
automatic background of black, we must fill it explicitly. */
white = gdImageColorAllocateAlpha (im_out, 255, 255, 255, 0);
gdImageFilledRectangle (im_out, 0, 0, gdImageSX (im_out),
gdImageSY (im_out), white);
green = gdImageColorAllocateAlpha (im_out, 0, 255, 0, 0);
gdImageFilledRectangle (im_out, 50, 10, 100,
gdImageSY (im_out)-10, green );
int ny, alpha;
int xmin, xmax, ymin, ymax, y1, y2;
xmin = 5;
xmax = gdImageSX(im_out)-5;
ymin = 5;
ymax = gdImageSY(im_out)-5;
ny = 100;
for (i=0; i<ny; i++) {
alpha = (i*gdAlphaMax)/(ny-1);
alpha = (alpha<0?0:alpha);
alpha = (alpha>gdAlphaMax?gdAlphaMax:alpha);
red = gdImageColorAllocateAlpha (im_out, 255, 0, 0, alpha);
/* Simulate shading */
y1 = ymin + (ymax-ymin)*i/ny;
y2 = ymin + (ymax-ymin)*(i+1)/ny;
points[0].x = xmin;
points[0].y = y1;
points[1].x = xmin;
points[1].y = y2;
points[2].x = xmax;
points[2].y = y2;
points[3].x = xmax;
points[3].y = y1;
/*gdImageSetAntiAliased (im_out, red);
gdImageFilledPolygon (im_out, points, 4, gdAntiAliased);*/
gdImageFilledPolygon (im_out, points, 4, red);
}
out = fopen ("test.png", "wb");
/* Write PNG */
gdImagePng (im_out, out);
fclose (out);
gdImageDestroy (im_out);
return 0;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel