loading an image causes EXCEPTION_ACCESS_VIOLATION

BlitzMax Forums/Brucey's Modules/loading an image causes EXCEPTION_ACCESS_VIOLATION

Peter(Posted 2010) [#1]
I'm trying to load GIF images with wxMax but so far I didn't found a working solution.

Does anyone has a clue what's wrong with my code?




rs22(Posted 2010) [#2]
I had this problem, too. I ended up using FreeImage to load the images:
Local freeimage:TFreeImage = LoadFreeImage("blah.gif")
Local bitmap:wxBitmap = New wxBitmap.CreateFromPixmap(ConvertPixmap(freeimage.GetPixmap(), PF_RGBA8888))
Local image:wxImage = bitmap.ConvertToImage()



Peter(Posted 2010) [#3]
Tried as you suggested, but there seem to be a problem with the FreeImage library.

I could build the mod without troubles but compiling my little test program ended in a massive amount of errors. Most of them read like the following:

C:/BlitzMax/mod/bah.mod/freeimage.mod/freeimage.debug.win32.x86.a(Plugin.cpp.debug.win32.x86.o):Plugin.cpp:(.text+0x4a8): 
  undefined reference to `_Unwind_Resume'


I tried it with the download version 1.05 and also with the latest svn release.

Maybe this is a compatibility problem with the latest BMax release.

I would appreciate if someone (Brucey?) has a clue for me how to solve this.

-- Peter


Peter(Posted 2010) [#4]
BTW, I also tried to build the associated samples for the FreeImage library.

Compiling the samples also failed with the same error as compiling my own stuff.

Brucey, will you have a look into this issue?

- Peter


Brucey(Posted 2011) [#5]
There's a bug in your code :
	'variables
		Local img:wxImage
	'code
		If Not img.CreateFromFile("prep.gif", wxBITMAP_TYPE_GIF) Then

This is invalid. CreateFromFile() is a Function, and therefore needs to be called using :
		If Not wxImage.CreateFromFile("prep.gif", wxBITMAP_TYPE_GIF) Then

Otherwise the program crashes on this line.
Interestingly, even in debug mode, it is a hard crash (1.41 OSX).