 |
| View previous topic :: View next topic |
| Author |
Message |
The2Saint Newbie
Joined: 06 Jun 2005 Posts: 3
|
Posted: Jul 15th, 2005 05:32 AM Post subject: Need help with FreeImage_LoadFromMemory |
|
|
Hello. I’m new to programming and freeimage and I’m having a problem that requires some skill and experience to solve. I’m trying to load a PNG from a Visual Basic 6 string into a FreeImage “memory file” and then save it. (I’ve been trying to follow the C++ example in the FreeImage manual).
The problem is that it outputs a 0 kB .ICO file. Dib also equals 0 after LoadFromMemory. How shall I modify/rewrite the code?
Here’s my code:
Private Sub Command1_Click()
Dim MyPNG As String 'It doesn't really have to be
'string if it doesn't work with strings.
'any data type will do.
MyPNG = LoadPNG(App.Path & "\PngFile.Png")
Dim dib As Long
Dim bOK As Long
' Load a png image
Dim MemHandlePNG As Long
MemHandlePNG = FreeImage_OpenMemory(StrPtr(MyPNG), Len(MyPNG))
dib = FreeImage_LoadFromMemory(fif_png, MemHandlePNG)
' Save this image as ICO
bOK = FreeImage_Save(fif_ico, dib, App.Path & "\IcoFile.ICO", 0)
' Unload the dib
FreeImage_Unload (dib)
FreeImage_CloseMemory (MemHandlePNG)
End Sub
Function LoadPNG(Path As String) As String
' This function will of course look different in the real app
' The PNGs will be Base64encoded
' I'm putting this simpler version here for demonstration
Open Path For Binary As 1
LoadPNG = Input(LOF(1), #1)
Close 1
End Function |
|
| Back to top |
|
DoobieKeebler Moderator

Joined: 17 Jun 2005 Posts: 254 Location: 181°15'2.003"W, 93°5'16.956"N
|
Posted: Jul 15th, 2005 07:47 AM Post subject: |
|
|
| I haven't worked with FreeImage yet. But I see they have a forum there. Your best bet would be to post on their forum. There's got to be a couple people there who have done something similar. |
|
| Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|