# Just Launched: You can now import projects and releases from Google Code onto SourceForge

We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps.

## Patch for triangle function

Andrea Charao
2009-04-10
2013-04-23

• Andrea Charao
2009-04-10

Hi,

The double version of pngwriter::triangle doesn't properly convert double to int, as other library functions do. This causes triangles to be invisible, depending on the rgb arguments (this is probably architecture dependent, too).

Below is the patch for this problem, even being it really simple to solve :-)

Btw, thanks for keep working on such useful library. I've been using it in some assignments for my CS students.

Cheers,
Andrea

--- pngwriter-0.5.4.orig/src/pngwriter.cc       2009-02-10 19:45:16.000000000 -0200
+++ pngwriter-0.5.4/src/pngwriter.cc    2009-04-10 17:01:05.000000000 -0300
@@ -4582,9 +4582,9 @@
void pngwriter::triangle(int x1, int y1, int x2, int y2, int x3, int y3, double red, double green, double blue)
{

-   this->line(x1, y1, x2, y2, ((int)65535*red), ((int)65535*green), ((int)65535*blue));
-   this->line(x2, y2, x3, y3, ((int)65535*red), ((int)65535*green), ((int)65535*blue));
-   this->line(x3, y3, x1, y1, ((int)65535*red), ((int)65535*green), ((int)65535*blue));
+   this->line(x1, y1, x2, y2, int(65535*red), int(65535*green), int(65535*blue));
+   this->line(x2, y2, x3, y3, int(65535*red), int(65535*green), int(65535*blue));
+   this->line(x3, y3, x1, y1, int(65535*red), int(65535*green), int(65535*blue));

}

• Paul Blackburn
2009-04-11

Hi Andrea,

Thank you very much for the patch. I will incorporate it in the next version.

Cheers!

Paul