On recommendation:
Backstory:
I wanted to write some type of wrapping around an object memory handler to deal with converting raw data into a FreeImage_BitMap and likewise, convert a FreeImage_BitMap into raw data of whatever type I selected for the output. There is valid strange reasons for this, example, dealing with a file which contains multiple packed images in bitmap format and you want to convert each of them into png format. The results so far is a class which takes a pointer to a block of memory, writes that block of memory to an INSTANCE array of bytes, and has handler's for reading and writing to that block of memory. So far, sounds good. The module (memloader.bas) also has wrappers for the calls FreeImage makes to gain access to this block of memory, each is rather simple in nature:
One of the things I needed to do, was to redefine one of the FreeImage DECLARES:
So that I could call the function. It all works once. Then crashes because somewhere, the Object's DESTROY is being called.
So, is it me or FreeImage?
PS: In the ZIP, the line to decomment, if it isn't already, is:
nFileType = FreeImage_GetFileTypeFromObject(fiIO, memHandle)
PSS: Another reason for trying to do things this was was to have it a bit extensible by being able to have multiple memory handler objects active.
(Updated the attachment with working example. 2/9/2009)
Originally posted by Chris Holbrook
View Post
I wanted to write some type of wrapping around an object memory handler to deal with converting raw data into a FreeImage_BitMap and likewise, convert a FreeImage_BitMap into raw data of whatever type I selected for the output. There is valid strange reasons for this, example, dealing with a file which contains multiple packed images in bitmap format and you want to convert each of them into png format. The results so far is a class which takes a pointer to a block of memory, writes that block of memory to an INSTANCE array of bytes, and has handler's for reading and writing to that block of memory. So far, sounds good. The module (memloader.bas) also has wrappers for the calls FreeImage makes to gain access to this block of memory, each is rather simple in nature:
Code:
FUNCTION FreeImage_MemoryReadData(BYVAL buffer AS DWORD, BYVAL dwSize AS DWORD, _ BYVAL dwCount AS DWORD, BYVAL fiHandle AS MemoryLoaderSystem) AS DWORD FreeImage_MemoryReadData = fiHandle.ReadData(buffer, dwSize, dwCount) END FUNCTION
Code:
DECLARE FUNCTION FreeImage_GetFileTypeFromObject _ LIB "FreeImage.dll" ALIAS "[email protected]" ( _ BYREF FreeImageIO, _ ' FreeImageIO *io BYVAL MemoryLoaderSystem, _ ' fi_handle handle OPTIONAL BYVAL LONG _ ' int size FI_DEFAULT(0) ) AS LONG ' FREE_IMAGE_FORMAT
So, is it me or FreeImage?
PS: In the ZIP, the line to decomment, if it isn't already, is:
nFileType = FreeImage_GetFileTypeFromObject(fiIO, memHandle)
PSS: Another reason for trying to do things this was was to have it a bit extensible by being able to have multiple memory handler objects active.
(Updated the attachment with working example. 2/9/2009)
Comment