Result = LoadImage(#Image, Filename$ [, Flags])
Load the specified image from an URL or a local file.


#Image A number to identify the loaded image. #PB_Any can be specified to auto-generate this number.
Filename$ The name of the file to load. The filename can be an URL or a local file (if the flag #PB_LocalFile is set).
Flags (optional) It can be one of the following value:
  #PB_LocalFile: the filename is a local file, OpenFileRequester()() needs to be called before
                 to have access to local files. SelectedFileID()() is used to get the
                 local file identifier.

Return value

Returns nonzero if a temporary image has been created or zero otherwise. The image is still not loaded, the callbacks binded to #PB_Event_Loading and #PB_Event_LoadingError will be called once the loading is done. If #PB_Any was specified as the #Image parameter then the auto-generated number is returned on success.

You can use the several other functions for acting with the loaded image:
StartDrawing() with ImageOutput() to draw on the loaded image
StartVectorDrawing() with ImageVectorOutput() to draw on the created image using vector drawing
CopyImage() to create another image from the actual one
GrabImage() to create another image from a given area of the actual one
DrawImage() with ImageID() to draw the image on actual output channel.
ImageGadget() for displaying image on an application window
ButtonImageGadget() for creating an image button on an application window

Example: with an URL

  Procedure Loaded(Type, Filename$, ObjectId)

    ; Display the image in a new window
    OpenWindow(#PB_Any, 10, 10, 300, 300, "Image", #PB_Window_SizeGadget)
      ImageGadget(#PB_Any, 0, 0, ImageWidth(ObjectId), ImageHeight(ObjectId), ImageID(ObjectId))
  Procedure LoadingError(Type, Filename$, ObjectId)
    Debug Filename$ + ": loading error"
  ; Register the loading event before calling any resource load command
  BindEvent(#PB_Event_Loading, @Loaded())
  BindEvent(#PB_Event_LoadingError, @LoadingError())
  LoadImage(0, "Data/SpiderBasicLogo.png")

Example: with local file

See Also

CreateImage(), CopyImage(), GrabImage(), ExportImage()

Supported OS


<- IsImage() - Image Index - ResizeImage() ->