CatchImage()
Syntax
Result = CatchImage(#Image, MemoryAddress [, Size])Description
Load the specified image from the given memory area. If #PB_Any is used as '#Image' parameter, the new image number will be returned as 'Result'. 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).
The image can be in BMP, icon (.ico, only on Windows) or any other format supported by the ImagePlugin library. If something wrong the 0 value is returned. A loaded image can be freed by using the FreeImage() function.
This function is useful when using the 'IncludeBinary' PureBasic keyword. Then images can be packed inside the executable. Nevertheless, use this option with care, as it will take more memory than storing the file in an external file (the file are both in executable memory and load in physical memory).
The optional 'Size' parameter specify the maximum size (in bytes) of the image to load. It can prevent a crash when trying to handle images from an unknown location, which can be corrupted.
The following functions can be used to enable automatically more image formats:
UseJPEGImageDecoder()
UseJPEG2000ImageDecoder()
UsePNGImageDecoder()
UseTIFFImageDecoder()
UseTGAImageDecoder()
Example:
CatchImage(0, ?Logo) End DataSection Logo: IncludeBinary "Logo.bmp" EndDataSectionNote: The "?" is a pointer to a label. More informations about pointers and memory access can be found in the relating chapter here. The image size is currently limited to 8192x8192 pixels (if the available memory allow it). On Windows, if the specified image is an icon (.ico), the following commands will not be available to manipulate it: SaveImage() and @fastimage"ImageOutput()".
Supported OS
All