gdImageCopyResampled broken when built with Visual C++ 2010 32-bit due to floor2() "smart" cast

Issue #12 resolved
Xavier Roche created an issue

The gdImageCopyResampled() function is broken when built with Visual C++ 2010 32-bit (with full optimization, -O2) due to floor2() "smart" cast. The result is generally a white image with colored artifacts, rather than the re-sampled image.

This is most probably a compiler optimization bug, so this is not directly a GD bug. But I open the ticket for people who might get similar troubles :)

The bug is triggered by the following line in gd.c: sx = floor2 (sx);

Possible fix is to do the following in gd.c:

{{{ #if (defined(_WIN32) && defined(_M_IX86) && defined(_MSC_VER) && _MSC_VER == 1600) / Do not use optimized version due to possible compiler bug with VC++2010/ix86. / #define floor2(exp) floor(exp) #else #define floor2(exp) ((long) (exp)) #endif }}}

Comments (7)

  1. Pierre Joye

    Please try using current master, this issue may look like a rounding issue in gdImageCopyResampled. A fix has been merged.

  2. Log in to comment