LoadImage()

Syntax

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

Parameters

#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. If the filename does not include a full path, it is interpreted relative to the current directory.
Flags (optional) This parameter currently has no meaning. If it is specified, 0 should be used for future compatibility.

Return value

Returns nonzero if the image was loaded successfully and zero if the image could not be loaded. If #PB_Any was specified as the #Image parameter then the auto-generated number is returned on success.

Remarks

The limit for the image size that can be handled depends on the operating system and the available amount of memory. If enough memory is available, then images up to at least 8192x8192 are can be handled by all operating systems supported by PureBasic.

When an image is loaded, it is converted either in 24-bit (if the image depth is less or equal to 24-bit) or in 32-bit (if the image has an alpha-channel). A loaded image can be freed by using the FreeImage() function.

The image can be in BMP, icon (.ico, only on Windows) or any other format supported by the ImagePlugin library. The following functions can be used to enable automatically more image formats:

UseJPEGImageDecoder()
UseJPEG2000ImageDecoder()
UsePNGImageDecoder()
UseTIFFImageDecoder()
UseTGAImageDecoder()

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.
DrawAlphaImage() with ImageID() to draw the image (with alpha channel) on actual output channel.
ImageGadget() for displaying image on an application window
ButtonImageGadget() for creating an image button on an application window

See Also

CreateImage(), CatchImage(), CopyImage(), GrabImage(), ImagePlugin library

Supported OS

All

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