开发者

Using PHP's GD functions, how can I create an ellipse that is anti-alised and has a transparent background (PNG24 with alpha)?

I'm able to draw a circ开发者_如何学运维le on a transparent background, but it's pixelated around the edges.

I can also get an anti-aliased circle on a non-transparent background with http://mierendo.com/software/antialiased_arcs/.

So, how do I get both?


The trouble with transparent images is that the half-transparent pixels at the border will be partly colored with the color you specified as the transparent color, if you can live with that then you can use the antialiased arcs library you specified, just put the following at the beginning of their example (I used the optimized version) :

include ("./imageSmoothArc_optimized.php");

$img = imageCreateTrueColor( 648, 800 );
imagealphablending($img,true);
$color = imageColorAllocate( $img, 255, 255, 255);
$transparent_color = imageColorAllocate( $img, 0, 0, 0);
imagefill( $img, 5, 5, $transparent_color );
imagecolortransparent($img, $transparent_color);

This will give you a transparent PNG image. Since I specified black as the transparent color, the circles will go to black near the edge, and you will only be able to use this on a dark background.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜