How to use freeimage.dll to load picture into either picture or image control using vb6?
Posted on 2004-11-12
How does one use freeimage.dll to load a picture into either a picture control or an image control. I'm using Visual Basic, version 6. I can load an image into memory and retrieve a handle for it OK, as such:
Dim TN as Long
FName = "mybmp.bmp"
TN = FreeImage_Load(FIF_BMP, FName, 0) 'where FIF_BMP = 0 and where FName is for a .bmp file.
Once loaded, I can perform operations on the graphic OK. For example, I can get the dimensions, as such:
'Get pic dimensions.
Debug.Print "Width: " & FreeImage_GetWidth(TN) & ", Height: " & FreeImage_GetHeight(TN)
So, I can use freeimage.dll to load the image and convert it, rescale it and perform other operations on it just fine except for one thing... how can I get that affected graphic loaded into a picturebox or an image control so that I can view it?
Freeimage.dll allows me to save the image to a file and I know how to do that. So, one method could be to save the image to disk as a .bmp and then use LoadPicture to load it into a picturebox (or image control or whatever). But, I don't want to have to save it to disk and then load it back in again.
Can I do it somehow using FreeImage_LoadFromHandle? Or maybe FreeImage_GetBits?
Looking forward to your replies.