Image not showing in window with ImageGadget

Just starting out? Need help? Post your questions and find answers here.
User avatar
Distorted Pixel
Enthusiast
Enthusiast
Posts: 303
Joined: Sun Aug 29, 2021 4:34 am

Image not showing in window with ImageGadget

Post by Distorted Pixel »

Hi,

I can't believe I'm having this problem. It is simple to do, but what is wrong with this code.
As the code is below, it shows a blank window.

If I use ImageID(Img_SplashScreen) in the place of the variable at the end of the ImageGadget, it says "[ERROR] The specified #Image is not initialized"

Code: Select all

Global Win_SplashScreen = 1
Global Img_SplashScreen = 1
Global Gadget_SplashScreen = 1

Flags = #PB_Window_BorderLess
OpenWindow(Win_SplashScreen, 0, 0, 1920, 1080, "European Football Simulator", Flags)

LoadImage(Img_SplashScreen, "Images\SplashScreen.png")

ImageGadget(Gadget_SplashScreen, 0, 0, 1920, 1080, Img_SplashScreen)

Repeat
  Event = WaitWindowEvent()
  
  
Until Event = #PB_Event_CloseWindow
To be popular is way to much work. I just want to be me, myself and I. Oh no, does that mean I'm bipolar? :shock:

No one cares how much you know until they know how much you care
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Image not showing in window with ImageGadget

Post by Paul »

UsePNGImageDecoder() ??
Image Image
Sergey
User
User
Posts: 53
Joined: Wed Jan 12, 2022 2:41 pm

Re: Image not showing in window with ImageGadget

Post by Sergey »

Hi,
1) UsePNGImageDecoder() at the beginning
2) ImageID(Img_SplashScreen)
And all will be ok ;-)
User avatar
Distorted Pixel
Enthusiast
Enthusiast
Posts: 303
Joined: Sun Aug 29, 2021 4:34 am

Re: Image not showing in window with ImageGadget

Post by Distorted Pixel »

Paul wrote: Thu Mar 27, 2025 12:55 am UsePNGImageDecoder() ??
LOL OOPS Yes I did forget that so I could use the ImageID(). Thank you
To be popular is way to much work. I just want to be me, myself and I. Oh no, does that mean I'm bipolar? :shock:

No one cares how much you know until they know how much you care
infratec
Always Here
Always Here
Posts: 7576
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Image not showing in window with ImageGadget

Post by infratec »

For that reason you should always check the return values.
LoadImage() returns 0 in your case.
User avatar
Distorted Pixel
Enthusiast
Enthusiast
Posts: 303
Joined: Sun Aug 29, 2021 4:34 am

Re: Image not showing in window with ImageGadget

Post by Distorted Pixel »

infratec wrote: Thu Mar 27, 2025 7:49 am For that reason you should always check the return values.
LoadImage() returns 0 in your case.
Yes, good idea thank you
To be popular is way to much work. I just want to be me, myself and I. Oh no, does that mean I'm bipolar? :shock:

No one cares how much you know until they know how much you care
Post Reply