Page 1 of 1

Please update LoadImage example "Help Text" code

Posted: Wed Nov 02, 2022 5:20 pm
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.

Re: Please update LoadImage example "Help Text" code

Posted: Wed Nov 02, 2022 10:07 pm
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().

Re: Please update LoadImage example "Help Text" code

Posted: Wed Nov 02, 2022 10:15 pm
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!

Re: Please update LoadImage example "Help Text" code

Posted: Thu Nov 03, 2022 8:05 am
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?