bah.freeimage + win7 + maxgui + iconstrip error

BlitzMax Forums/Brucey's Modules/bah.freeimage + win7 + maxgui + iconstrip error

SB(Posted 2009) [#1]
After importing the freeimage mod my maxgui app just crashed with a windows "Program has stopped working" error and without any debug info. After a little bit of research i narrowed it down to the following code snippet. The crash occurs somewhere in the LoadPixmap function.

Local mainWin_Icons:TPixmap = LoadPixmap(My.Resources.media.toolbar_bmp)
Local mainWin_Strip:TIconStrip = LoadIconStrip(mainWin_Icons)
mainWin_Toolbar = CreateToolbar( "",0,0,0,0, mainWin )
	SetGadgetIconStrip(mainWin_Toolbar, mainWin_Strip)


*Update*
I tracked it further down to the function where it goes through all the different pixmap loaders and checks if they are returning a pixmap. the crash happens when it is useing the jpg loader. so it is actually working with a png because the pngloader is tried before the jpg loader. Actually the error occurs in jpgloader.bmx on line 65 which is not part of freeimage, however if I don't use the freeimage import, i won't get the error. Perhaps the order of the pixmap loaders gets changed by adding freeimage thus triggering the error.


Difference(Posted 2009) [#2]
A shot in the dark but, look at /Community/posts.php?topic=82586#933350

Do you have the config folder included?


Brucey(Posted 2009) [#3]
Actually the error occurs in jpgloader.bmx on line 65 which is not part of freeimage, however if I don't use the freeimage import, i won't get the error.

You shouldn't use the built-in image loaders if you are using BaH.FreeImage.

FreeImage uses its own copies of LibPNG and LibJPEG, which can cause issues if your binary also has copies of those libraries from the Pub.* namespace.
The specific issue is that some functions from one copy will be linked into your binary, but other functions from the other copy will be used - and mixing parts of a library from different versions isn't a good idea.

If you use Framework - which ideally you will be, you only import BaH.FreeImage, and not any of the BRL.* loaders.

FreeImage supports all of the default BlitzMax image loader formats.
BaH.FreeImage is designed as a drop-in replacement for the built-in loaders, and should work transparently with LoadPixmap().


SB(Posted 2009) [#4]
Thank you. I now understand the problem. I will use Framework.