Please update LoadImage example "Help Text" code

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
HwyStar
Enthusiast
Enthusiast
Posts: 101
Joined: Mon Apr 05, 2010 7:13 pm
Location: Reno, Nevada

Please update LoadImage example "Help Text" code

Post by HwyStar »

The ImageGadget() help text needs to be updated. The help text does not mention using one or all of the Decoders(). Please update it to this:

Code: Select all

UseJPEGImageDecoder()
UseTGAImageDecoder()
UsePNGImageDecoder()
UseTIFFImageDecoder()
UseGIFImageDecoder()

  If OpenWindow(0, 0, 0, 245, 105, "ImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If LoadImage(0, "map.bmp")    ; change 2nd parameter to the path/filename of your image
      ImageGadget(0,  10, 10, 100, 83, ImageID(0))                      ; imagegadget standard
      ImageGadget(1, 130, 10, 100, 83, ImageID(0), #PB_Image_Border)     ; imagegadget with border
    EndIf
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf  
It's up to the programmer which decoder to use but without an applicable decoder the LoadImage fails and never talks about it in the help text!

I am testing this on Mac but I think the same results happen on Windows.
BarryG
Addict
Addict
Posts: 4122
Joined: Thu Apr 18, 2019 8:17 am

Re: Please update LoadImage example "Help Text" code

Post by BarryG »

HwyStar wrote: Wed Nov 02, 2022 5:20 pmwithout an applicable decoder the LoadImage fails and never talks about it in the help text!
Yes, it does:

https://www.purebasic.com/documentation ... image.html

Image

The ImageGadget() will thus use whatever valid image format has been loaded with LoadImage().
User avatar
HwyStar
Enthusiast
Enthusiast
Posts: 101
Joined: Mon Apr 05, 2010 7:13 pm
Location: Reno, Nevada

Re: Please update LoadImage example "Help Text" code

Post by HwyStar »

My bad... But, the command that really needs the help text updated is ImageGadget:

All it has in the example code for ImageGadget is this:

Code: Select all

 If OpenWindow(0, 0, 0, 245, 105, "ImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If LoadImage(0, "map.bmp")    ; change 2nd parameter to the path/filename of your image
      ImageGadget(0,  10, 10, 100, 83, ImageID(0))                      ; imagegadget standard
      ImageGadget(1, 130, 10, 100, 83, ImageID(0), #PB_Image_Border)     ; imagegadget with border
    EndIf
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
That will not work for jpg or png files. I now understand that LoadImage requires that code, but an image will not display without the decoders. ImageGadget does not show us that!
User avatar
HeX0R
Addict
Addict
Posts: 1187
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: Please update LoadImage example "Help Text" code

Post by HeX0R »

In fact LoadImage() fails, if you are trying to load an image without the correct decoder, and in your example code ImageGadget() would not even been called.
So why should it be in the help part of ImageGadget(), when the programmer is trying to call it with an uninitialized picture?
Post Reply