LoadImage()

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Keith.

Hi,

This Code wont load the image into the image gadget dose anyone have any idea why?

Code: Select all

If OpenWindow(1,0,0,250,150,#PB_Window_ScreenCentered | #PB_Window_SystemMenu,"Test")
   CreateGadgetList(WindowID())
   
   LoadImage(0,"image.bmp")
   ImageGadget(1,0,0,100,100,UseImage(1))
      
   Repeat
      Select WindowEvent()
         Case #PB_Event_CloseWindow
            End
      EndSelect
   ForEver
EndIf
Thanks

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

Post by BackupUser »

Restored from previous forum. Originally posted by WolfgangS.

HI!
Write ImageGadget(1,0,0,100,100,ImageID())
instead of ImageGadget(1,0,0,100,100,UseImage(1))

UseImage(1) just try to activate an Image with the ID 1 (which even isn't loaded :wink:
ImageID() gives you the handle (in PureBasic the "ID") from the Image you need.
Hint: Use WaitWinodwEvent() instead of WindowEvent()

I would write this:

Code: Select all

#ID_MWidnow  = 0
#ID_Image1    =10
#ID_IGadget1  =20

hnd_MWindow.l         ; handle  of the MotherWindow
WEvent.l              ; Event's of the MotherWindow

hnd_MWidnow=OpenWindow(#ID_MWidnow,0,0,250,150,#PB_Window_ScreenCentered|#PB_Window_SystemMenu,"Test")

  If LoadImage(#ID_Image1,"e:\font2.bmp")=0
    beep_(100,1000):End
  EndIf
  
  If CreateGadgetList(WindowID())=0
    beep_(100,1000):End
  Else
    ImageGadget(#ID_IGadget1,0,0,100,100,ImageID())
  EndIf
      
  Repeat
    WEvent=WaitWindowEvent()
  Until WEvent=#PB_Event_CloseWindow
MFG
:)WolfgangS
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Keith, there is an error in your code,because you do:

LoadImage(0,"image.bmp")

ImageGadget(1,0,0,100,100,UseImage(1))

You load an image with the number 0 but USE an IMAGE with number 1.
There is no image with number 1. Only number 0.

Should be:

ImageGadget(1,0,0,100,100,UseImage(0))

Have a nice day...

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

Post by BackupUser »

Restored from previous forum. Originally posted by Keith.

Thanks
Post Reply