CatchSprite()
Syntax
Result = CatchSprite(#Sprite, *MemoryAddress [, Mode])Description
Loads the specified sprite from the given memory area. A screen should be opened with OpenScreen() or OpenWindowedScreen() before loading a sprite. Sprites can be in BMP format or any other format supported by the ImagePlugin library. A catched sprite can be freed by using the FreeSprite() function. The 'CatchSprite' function is useful when using the 'IncludeBinary' PureBasic keyword. The images can be packed inside the executable. Nevertheless, use this option very carefully, as it will take more memory than storing the file in an external file (the file will be in both executable memory and loaded into physical memory).
The following functions can be used to enable automatically more image formats:
UseJPEGImageDecoder()
UseJPEG2000ImageDecoder()
UsePNGImageDecoder()
UseTIFFImageDecoder()
UseTGAImageDecoder()
Parameters
#Sprite A number to identify the new sprite. #PB_Any can be used to auto-generate this number. *MemoryAddress The memory address holding the image used to create the sprite. Mode (optional) It can be a combination of the following values (with the '|' operator): #PB_Sprite_PixelCollision: Add special information to handle pixel collision trough SpritePixelCollision(). #PB_Sprite_AlphaBlending : Sprite is created with per pixel alpha-channel support, needed for DisplayTransparentSprite(). The image format has to support it (only PNG and TIFF for now).
Return value
Nonzero if the sprite has been created, zero otherwise. If #PB_Any was used for the #Sprite parameter then the generated number is returned on success.
Example
Debug CatchSprite(0, ?Pic) DataSection Pic: IncludeBinary "Sprite.bmp" EndDataSection
Remarks
The "?" is a pointer to a label. More information about pointers and memory access can be found in the relating chapter here.
See Also
CreateSprite(), LoadSprite()
Supported OS
All