FreeImage LIB

Blitz3D Forums/Blitz3D Programming/FreeImage LIB

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

FIXED! *wipes sweat from brow*

Ok, replace the FIQSend() function in your FreeImage3D.bb with this new one:

Function FIQSend(Image)

; ### 16-bit fix by VIP3R (Jim Williams)
; ### Now works with both 16-bit and 32-bit depth

Local iBuffer%, iPitch%, iFormat%
Local FIBITMAP%, nFIBITMAP%, iBank%

iBuffer=ImageBuffer(Image)

LockBuffer iBuffer

iBank=FI_PeekIntEx(iBuffer,72)
iPitch=FI_PeekIntEx(iBuffer,56)

If iPitch=3200
	ROffset=112
	GOffset=116
	BOffset=120
	End If

If iPitch=1600
	ROffset=120
	GOffset=116
	BOffset=112
	End If

FIBITMAP=FI_ConvertFromRawBits3D(iBank,ImageWidth(Image),ImageHeight(Image),iPitch,FI_PeekIntEx(iBuffer,100),FI_PeekIntEx(iBuffer,ROffset),FI_PeekIntEx(iBuffer,GOffset),FI_PeekIntEx(iBuffer,BOffset),0)

UnlockBuffer iBuffer

If FI_GetBPP(FIBITMAP)<>24
	nFIBITMAP=FI_ConvertTo24Bits(FIBITMAP)
	If nFIBITMAP
		FI_Unload FIBITMAP
		FIBITMAP=nFIBITMAP
		EndIf
	EndIf
	
Return FIBITMAP

End Function


Works properly now in both 16-bit and 32-bit modes ;)