Page 1 of 1

Posted: Thu Apr 04, 2002 9:59 am
by BackupUser
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.

Posted: Thu Apr 04, 2002 10:41 am
by BackupUser
Restored from previous forum. Originally posted by El_Choni.

You can use a label pointer as a value instead of UseImage():

Code: Select all

MyImage:
IncludeBinary "C:\myimage.bmp"
And:

Code: Select all

StartDrawing(WindowOutput())
DrawImage(?MyImage, 0, 0)
StopDrawing()
Or:

Code: Select all

ImageGadget(0, 0, 0, Width, Heigth, ?MyImage) 
I can't test this now, but it should work.

Bye,



El_Choni

Edited by - El_Choni on 04 April 2002 18:32:39

Posted: Fri Apr 05, 2002 10:42 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.
You can use a label pointer as a value instead of UseImage():
Did you actually get this to work, it's not working for me. All i get is assembly error!

Posted: Fri Apr 05, 2002 11:25 pm
by BackupUser
Restored from previous forum. Originally posted by skypa.
You can use a label pointer as a value instead of UseImage():
Did you actually get this to work, it's not working for me. All i get is assembly error!
Same here.

Posted: Sat Apr 06, 2002 3:13 am
by BackupUser
Restored from previous forum. Originally posted by Franco.

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
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

Posted: Sat Apr 06, 2002 1:11 pm
by BackupUser
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