FreeImage LoadPixmap crash, and flip issue

BlitzMax Forums/Brucey's Modules/FreeImage LoadPixmap crash, and flip issue

ima747(Posted 2009) [#1]
SuperStrict

'Import BaH.FreeImage

Graphics(800, 600, 32, 2)

Local pixm:TPixmap = LoadPixmap("flip.jpg")
Cls()
DrawPixmap(pixm, 0, 0)
Flip()

While(Not KeyHit(KEY_Escape))

Wend


this crashes if you uncomment FreeImage. Seems to crash on the LoadPixmap(). Happens in 1.05 and 1.06 SVN I just downloaded. (947) in either I can use LoadFreeImage() and then GetPixmap() from the freeImage and it works fine.

Additionally when calling rescale or MakeThumbnail on certain pictures the image gets flipped vertically. Calling ConvertToType(FIT_BITMAP) before scaling prevents the flip. It only happens on a couple pictures (jpgs) out of a bunch I got from one user. If you want to provide an email address I can forward one of the offenders, but I can't post it publicly since I don't have permission.


Brucey(Posted 2009) [#2]
See here and/or here for an explanation of your crash issue.

My email address is in my profile page.


ima747(Posted 2009) [#3]
Photo forwarded, thanks!


Brucey(Posted 2009) [#4]
Okay, I've fixed it.

It turns out, that for greyscale images, it was using the original FreeImage bitmap for display, rather than creating a copy of it, and processing the copy instead.
Internally, I have to "flip" the image that you see as a Pixmap, because FreeImage holds image data upside-down. The reason that it shouldn't change the original data to present it as a Pixmap, should be quite obvious. :-)

Anyhoo, apologies for the trouble, and thanks for the example image.