Restored from previous forum. Originally posted by skypa.
Hi,
if I add a binary to my exe with IncludeBinary, I can copy this directly to an allocated memory bank with CopyMemory. But is there a possibility to load an image from memory, because LoadImage only supports $FileName and not *MemoryBuffer.
Load image from memory?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by El_Choni.
You can use a label pointer as a value instead of UseImage():
And:
Or:
I can't test this now, but it should work.
Bye,
El_Choni
Edited by - El_Choni on 04 April 2002 18:32:39
You can use a label pointer as a value instead of UseImage():
Code: Select all
MyImage:
IncludeBinary "C:\myimage.bmp"
Code: Select all
StartDrawing(WindowOutput())
DrawImage(?MyImage, 0, 0)
StopDrawing()
Code: Select all
ImageGadget(0, 0, 0, Width, Heigth, ?MyImage)
Bye,
El_Choni
Edited by - El_Choni on 04 April 2002 18:32:39
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
The following code:
crashes only if there is no 'END' or the SubRoutine (without 'Return') comes before the normal code.
The bad thing is: the image is saved in the exe (you can see it at the file size) but I can't see it on the window.
I suppose the problem is:
The 'DrawImage' command needs a Image NUMBER NOT A POINTER.
And 'LoadImage' accepts only strings no pointer.
How to grab the Image (Subroutine pointer) and give them a Image NUMBER?
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
Edited by - franco on 06 April 2002 04:16:57
The following code:
Code: Select all
If OpenWindow(0, 200, 200, 320,240, #PB_Window_SystemMenu ,"Test Window")
StartDrawing(WindowOutput())
DrawImage(?MyImage, 0, 0)
StopDrawing()
Repeat
EventID.l = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
EndIf
End
MyImage:
IncludeBinary "c:\purebasic\data\background.bmp"
Return
The bad thing is: the image is saved in the exe (you can see it at the file size) but I can't see it on the window.
I suppose the problem is:
The 'DrawImage' command needs a Image NUMBER NOT A POINTER.
And 'LoadImage' accepts only strings no pointer.
How to grab the Image (Subroutine pointer) and give them a Image NUMBER?
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
Edited by - franco on 06 April 2002 04:16:57
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by El_Choni.
I'm sorry this didn't work, I wrote it from memory (my memory), Anyway, I posted weeks ago an example in teh tricks'n'tips sections which, among other things, shows how to load and show an image from memory. I don't have PB here, so I can't test things now, sorry.
Bye,
El_Choni
I'm sorry this didn't work, I wrote it from memory (my memory), Anyway, I posted weeks ago an example in teh tricks'n'tips sections which, among other things, shows how to load and show an image from memory. I don't have PB here, so I can't test things now, sorry.
Bye,
El_Choni