Patch for win-amd64
Brought to you by:
michelepetrazzo
The attached patch allows to use FreeImagePy on 64-bit Python for Windows. The patch is rather large due to automatic code reformatting by my editor (sorry). The __ctrlColorUsed function was improved by using a function dictionary lookup instead of iterating through the function list. The test.py and test_old.py scripts now succeed on Python 2.6.4 for Windows 64-bit with FreeImage.dll version 3.13.0 compiled with Visual Studio 2008. Hope this helps.
First of all, thanks for the patch.
Can you please send me only the "real" diff? I can't found where you modify the sources. A simple method can be to save with windows end line and after modify that source. After you can create the patch, that I think will be smaller than 150k :).
Another method it's to checkout from svn the sources and, from the command line do: svn diff -x --ignore-eol-style -w
Michele
I am unable to produce a shorter patch (sorry). Most changes are due to my editor PEP8-fying the code: indenting with 4 spaces, trimming whitespace, and wrapping lines at 80 characters.
The functional changes are in 3 files (attached): library.py, funct_list.py, and FreeImagePy.py.
In library.py, line 133 now reads:
if sys.platform == 'win32' and '64 bit' not in sys.version:
In func_list.py, added a line at the end:
FUNCTION_DICT = dict((i[0], tuple(i[1:])) for i in FUNCTION_LIST)
FreeImagePy.py contains the most changes:
* imported FUNCTION_DICT instead of FUNCTION_LIST
* rewrote the __ctrlColorUsed function to use FUNCTION_DICT
* renamed all variable and function argument names that shadowed built-in names, e.g. type and format
* Changed all __lib function calls that take bitmap as argument, e.g.
self.__lib.function_name(bitmap)
to
self.__lib.function_name(C.c_void_p(bitmap))
Christoph