Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Interface and Graphics

Post new topic   Reply to topic
Need help with FreeImage_LoadFromMemory
View previous topic :: View next topic  
Author Message
The2Saint
Newbie


Joined: 06 Jun 2005
Posts: 3

PostPosted: Jul 15th, 2005 05:32 AM    Post subject: Need help with FreeImage_LoadFromMemory Reply with quote

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
View user's profile Send private message Send e-mail
DoobieKeebler
Moderator


Joined: 17 Jun 2005
Posts: 254
Location: 181°15'2.003"W, 93°5'16.956"N

PostPosted: Jul 15th, 2005 07:47 AM    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Interface and Graphics All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic