bah.freeimage TIFF crash

BlitzMax Forums/BlitzMax Programming/bah.freeimage TIFF crash

fredborg(Posted 2007) [#1]
Hi,

bah.freeimage crashes when loading TIFF images for me. It seems TIFF saving is also broken.

Anybody else getting this?


Brucey(Posted 2007) [#2]
Do you have an example tiff to test with?

The one (logo.tif) in the tests folder seems to load okay (Mac, Intel). It was created with Gimp on Linux.

Will give it a go on XP.


Brucey(Posted 2007) [#3]
Tests using the same tiff on XP worked too (XP running on Parallels, Max 1.28)


fredborg(Posted 2007) [#4]
Hi,

I have a ton of files which won't load, they seem to crash FreeImages TIFF loader, yet they load in everything else. They're saved from Photoshop, so they should be valid.

A single test: http://www.frecle.net/misc/3712_sten01_front.tif

Also I cannot save any tif images. The following code shows both errors on my machine at least:
SuperStrict

Import bah.freeimage

Graphics 640,480

'
' Crashes FreeImage
Local s:TStream = ReadFile("3712_sten01_front.tif")
If s
	Local f:TFreeImage = TFreeImage.CreateFromStream(s)
	CloseStream s

	Local p:TPixmap = f.GetPixmap()
	
	DrawPixmap(p,0,0)
	Flip
	WaitKey()
EndIf

'
' Won't save ... reports: data is invalid
Local p:TPixmap = CreatePixmap(512,512,PF_RGBA8888)
Local f:TFreeImage = TFreeImage.CreateFromPixmap(p)
If f
	If f.Save("test.tif",FIF_TIFF) = False
		Print "File did not save"
	EndIf
EndIf
Resaving the file from XnView cures the problem, and the test.tif loads without problems. I have no idea what the problem is.


Brucey(Posted 2007) [#5]
Tracked down the save problem... looks like a bug in libtiff, or... an issue with FreeImage feeding libtiff the correct details. Anyhoo, a fix to the libtiff code gets tiff saving working on OS X.
Of course, since FreeImage doesn't compile under MinGW, makes it interesting to fix it for Win32...


Brucey(Posted 2007) [#6]
Ah haa... the metadata breaks FreeImage (on Win32!) ;-)

I imagine that saving from XnView strips out the metatdata.

Digging deeper...


Brucey(Posted 2007) [#7]
Apparently, the ISOSpeedRatings exif field is meant to be a Short. In your Tiff it has a "sequence" of values in it.

Either the file is wrong, or libtiff is wrong... either way something needs a fixin' :-p


Brucey(Posted 2007) [#8]
Hokay... sorted out a workaround.

New version (when I get it online) updates to FreeImage 3.10, which apparently has new support for EXR and Jpeg2000, as well as fixing some bugs that I had worked around previously.

Also removes the need for a separate DLL on Windows, as I've managed to get it to compile under MinGW (why oh why they can't have this facility as standard, rather than me having to ****** around with defines.. :-p )


Difference(Posted 2007) [#9]
Also removes the need for a separate DLL on Windows
Awsome!


Brucey(Posted 2007) [#10]
For the daring amongst you... the latest source is available from the Subversion repository at http://maxmods.googlecode.com/

Once I've run tests on all platforms, I'll consider doing a "proper" release.

fredborg, your test app seems to works with this version on Win32, and now doesn't require a separate FreeImage.dll.


Feedback appreciated :-)


fredborg(Posted 2007) [#11]
Yay!

Loading and saving both works perfectly as far as I can tell. Thanks for the fix Brucey!

And very cool to get rid of the freeimage.dll. Excellent work!


xlsior(Posted 2007) [#12]
Sounds very nice, will definitely check this out later.


Brucey(Posted 2007) [#13]
Hmmm... well, there's something you don't expect - Mac Intel's rgb byte-order is the same as the PPC - but different to Win32...