Dear All,
I am having problems saving an image to a memory stream to use it in an
API function. The error occurs in the save method of the bitmap. It tells me
that the arguement cannot be optional, yet when I look in the object browser
it tells me that for the overloaded function I am using that I only need two
parameters for this particular function. If you have any help with this or
help on how to create an API comaptiple pointer to a System.IO.MemoryStream,
which was part of a previous post that I made, it would be greatly
appreciated. Thank you very much for your time and consideration in this
matter. Here is the code:
Public Function SaveImageToMem(ByVal ImageToConvert As Bitmap) As IntPtr
Try
Dim ImgMemStream As System.IO.MemoryStream
'Error Occurs After This line
ImageToConvert.Save(ImgMemStream, ImageToConvert.RawFormat) '<-
Error occurs here! Error is that an arguement cannot be null, yet I am using
this function correctly, what gives?
Dim PtrMemory As IntPtr =
Marshal.GetIDispatchForObject(ImgMemStream) '<- I am not sure if this is the
right way to to this, any help would be great, Thanks!
Return PtrMemory
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error Performing
Operation!")
End Try
End Function
And here is the API function that I want to pass the pointer to .... It is
part of the FreeImage Library, which you can download at
http://freeimage.sourceforge.net!
DLL_API Long *DLL_CALLCONV FreeImage_LoadFromMemory(FREE_IMAGE_FORMAT fif,
Long *stream, int flags FI_DEFAULT(0));