- #10, gdImageFilledEllipse does not respect transparency (rewriten)

master
pajoye 2006-10-10 00:40:41 +00:00
parent 50043ec4fa
commit ada1a438e1
3 changed files with 72 additions and 2 deletions

View File

@ -26,3 +26,4 @@ GDBUGS NEWS
RANLIB handling
configure.ac: AC_PROG_RANLIB is obsolete, now handled by AC_PROG_LIBTOO
#10, gdImageFilledEllipse does not respect transparency

View File

@ -1,3 +1,4 @@
/* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -1576,9 +1577,56 @@ BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h,
}
}
BGD_DECLARE(void) gdImageFilledEllipse (gdImagePtr im, int cx, int cy, int w, int h, int color)
BGD_DECLARE(void) gdImageFilledEllipse (gdImagePtr im, int mx, int my, int w, int h, int c)
{
gdImageFilledArc (im, cx, cy, w, h, 0, 360, color, gdPie);
int x=0,mx1=0,mx2=0,my1=0,my2=0;
long aq,bq,dx,dy,r,rx,ry,a,b;
int i;
int old_y1,old_y2;
a=w>>1;
b=h>>1;
gdImageLine(im, mx-a, my, mx+a, my, c);
mx1 = mx-a;my1 = my;
mx2 = mx+a;my2 = my;
aq = a * a;
bq = b * b;
dx = aq << 1;
dy = bq << 1;
r = a * bq;
rx = r << 1;
ry = 0;
x = a;
old_y2=-2;
old_y1=-2;
while (x > 0){
if (r > 0) {
my1++;my2--;
ry +=dx;
r -=ry;
}
if (r <= 0){
x--;
mx1++;mx2--;
rx -=dy;
r +=rx;
}
if(old_y2!=my2){
for(i=mx1;i<=mx2;i++){
gdImageSetPixel(im,i,my1,c);
}
}
if(old_y2!=my2){
for(i=mx1;i<=mx2;i++){
gdImageSetPixel(im,i,my2,c);
}
}
old_y2 = my2;
old_y1 = my1;
}
}
BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)

21
src/tests/bug00010.c Normal file
View File

@ -0,0 +1,21 @@
/* $Id$ */
#include "gd.h"
int main()
{
gdImagePtr im;
FILE *fp;
im = gdImageCreateTrueColor(100,100);
gdImageFilledEllipse(im, 50,50, 70, 90, 0x50FFFFFF);
fp = fopen("bug00010_out.png", "wb");
gdImagePng(im, fp);
fclose(fp);
/* Destroy it */
gdImageDestroy(im);
return 0;
}