Share

PNGwriter

The forum address has changed, you have been automatically redirected. Please update any bookmarks to use the new URL.

Subscribe

Patch for triangle function

You are viewing a single message from this topic. View all messages.

  1. 2009-04-10 21:23:13 UTC
    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));

    }
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.