Hi, Your example seems ok, but of course I have no idea what is in the file you load in, whether it loaded fine, or in what manner "it failed".
From the manual: > Polygon > > This function takes an array of integer values containing the > coordinates of the vertexes of a polygon. Note that if you want a > closed polygon, you must repeat the first point's coordinates for > the last point. It also requires the number of points contained in > the array. For example, if you wish to plot a triangle, the array > will contain 6 elements, and the number of points is 3. Be very > careful about this; if you specify the wrong number of points, your > program will either segfault or produce points at nonsensical > coordinates. The colour components are either doubles from 0.0 to > 1.0 or ints from 0 to 65535. > > > void polygon( int * points, int number_of_points, > double red, double green, double blue); > void polygon( int * points, int number_of_points, > int red, int green, int blue); Here's the code I used when I wrote the poly function. > #include <pngwriter.h> > > > int main() > { > int pts[8]; > > pts[0] = 9; > pts[1] = 190; > > pts[2] = 50; > pts[3] = 50; > > pts[4] = 199; > pts[5] = 150; > > pts[6] = 9; > pts[7] = 190; > > pngwriter image(200,200,0,"out-double.png"); > image.square(20,10,40,40,1.0,0.0,0.0); > image.circle(100,100,50,1.0,0.0,0.0); > > pngwriter image2(200,200,0,"out-int.png"); > image2.square(20,10,40,40,1.0,0.0,0.0); > image2.circle(100,100,50,1.0,0.0,0.0); > > image.boundary_fill( 30,12,65535,0,0,0,65535,0); > image2.boundary_fill( 30,12,1.0,0.0,0.0,0.0,1.0,0.0); > std::cout << "Done boundary." << std::endl; > image.flood_fill( 1,1,0,65535,0); > image2.flood_fill( 1,1,0.0,1.0,0.0); > std::cout << "Done fill." << std::endl; > image.polygon( pts, 4,65535,0,65535); > image2.polygon( pts, 4,1.0,0.0,1.0); > std::cout << "Done poly." << std::endl; > > image.flood_fill( 50,150,65535,0,0); > image2.flood_fill( 50,150,1.0,0.0,0.0); > > image.close(); > image2.close(); > > > > return 0; > > } Good luck. Paul On 25 Jul 2006, at 21:30, hu ting wrote: > hello,everyone. pngwriter is a good tool to plot image. now I need use > the polygon mothod, and I found > --------------------- > void polygon( int * points, int number_of_points, > > double red, double green, double blue); > > void polygon( int * points, int number_of_points, > > int red, int green, int blue); > --------------------- > but I can not find any example. I try like this > ----------------- > .... > int *pn=new int[pnum*2]; > for(int i=0;i { > int p; > ifile>>p; > pn[i*2]=(int)px[p]*100; > pn[i*2+1]=(int)py[p]*100; > } > image.polygon(pn,pnum,1.0,0.0,0,0); > ...... > --------------------- > but failed:( > > who can give me a example of the polygon?? thanks a lot! > ---------------------------------------------------------------------- > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys -- and earn > cash > http://www.techsay.com/default.php? > page=join.php&p=sourceforge&CID=DEVDEV________________________________ > _______________ > http://pngwriter.sourceforge.net/ > PNGwriter-users mailing list > PNGwriter-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pngwriter-users ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ http://pngwriter.sourceforge.net/ PNGwriter-users mailing list PNGwriter-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pngwriter-users