ID:               22103
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Verified
 Bug Type:         GD related
 Operating System: Linux
 PHP Version:      4.3.0
 New Comment:

Hello,

Thank's for the report.

<Since I'm doing a lot of graphic stuff I'll see if I can come up with
a new algorithm to do this. I'm afraid however that any correct
algortihm will be quite CPU expensive.>

I have already solved this problem with a quit nice and fast algorithm.
I have to check if I can add it to the current 4_3 HEAD.

Doing something better with ellipse then what GD currently does is not
very difficult (actually it's nothing else than a filled polygon with
many connected lines, kind of ugly things to draw a simple ellipse).

pierre



Previous Comments:
------------------------------------------------------------------------

[2003-02-07 11:06:00] [EMAIL PROTECTED]

I had a look in the source in GD. 
The problem is the way the gdImageFilledArc() is implemented. 

The algorithm there is flawed for alpha-blending. It fills the arc by
drawing a series of filled polygons (triangles) centerd in the middle
of the ellipse and out to the edge of the ellipse with 1 degree
separation between the end points. This will make the interior points
overlap and create the moire pattern.

Unfortunately there isn't a simple solution to this. Doing a floodfill
to a specific color wan't work since we don't know the canvas we are
drawing on.

Since I'm doing a lot of graphic stuff I'll see if I can come up with a
new algorithm to do this. I'm afraid however that any correct algortihm
will be quite CPU expensive.

------------------------------------------------------------------------

[2003-02-07 09:44:44] [EMAIL PROTECTED]

The problem still exist in snapshot 200302071430. 

I haven't had time to look at the GD code but this is most likely a
design flaw and not a straight bug. Fixing this will probably require a
new fill algorithm for ellipses that can guarantee that the same pixel
inside the ellipse will only be painted exactly one time.

The script below demonstrates this bug
and the resulting image can also be viewed at
http://www.aditus.nu/jpgraph/bbimages/filledellipsebug.png


<?php
header("Content-type: image/png");

// Create a truecolor image with alpha blending
$im = imagecreatetruecolor(200,200);
imagealphablending ($im,true);

// Background color
$bkg = imagecolorresolvealpha($im, 255,255,255,0);

// Red with ~70% alpha blending (90/127)
$red = imagecolorresolvealpha($im, 255,0,0,90);

// White background
imagefilledrectangle($im,0,0,200,200,$bkg);

// Filled circle (with moire' patterns)
imagefilledellipse($im,100,100,120,120,$red);

imagepng($im);
imagedestroy($im);
?>

------------------------------------------------------------------------

[2003-02-07 06:36:22] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip


There were couple of fixes in GD in CVS.
If it still fails, please provide a short example script.


------------------------------------------------------------------------

[2003-02-06 22:18:03] [EMAIL PROTECTED]

(Using built-in GD 2.x in PHP 4.3.0)

imagefilledellipse() creates moire' patterns inside the filled ellipse
when alpha blending is enabled.

The problem seems to be that the fill algorithm strokes the same point
within the ellipse several times and due to the alpha blending of
single pixels creates several color shades within the ellipse.

This is fine as long as a solid fill is used but does not work together
with alpha blending. 



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=22103&edit=1

Reply via email to