CRM64Pro GDK v0.14.0
A free cross-platform game development kit built on top of SDL 3.0
Loading...
Searching...
No Matches
CRM64Pro::ImageMgr

Image Manager class. More...

Detailed Description

Image Manager class.

Public Member Functions

bool info (Sint32 iMode=0) override
 Request Image Manager information.
Sint32 create (const string &sName, Uint32 iVersion=10) override
 Creates a new image.
bool close (Sint32 idImg) override
 Close and destroy an image.
Sint32 getCount () const override
 Get number of loaded objects.
Sint32 setName (Sint32 idImg, const string &sName) override
 Change the object name.
bool closeEx (Sint32 idImg, Uint32 iOwner)
 Close and destroy an image.
Imageget (Sint32 idImg)
 Get a pointer to the image using its handler.
Sint32 duplicate (Sint32 idImg, const string &sName)
 Duplicate an image creating a new, identical and independent one.
Sint32 child (Sint32 idImg)
 Create a child image dependent on the provided one (the parent).
bool isBMP (const string &sFile)
 Check if the file is a BMP.
bool isPNG (const string &sFile)
 Check if the file is a PNG.
Sint32 loadFromFile (const string &sFile, const string &sName="")
 Load an image from an external file (BMP or PNG formats).
Sint32 load (const string &sCDCFile, const string &sName)
 Load an image stored in a CDC file.
Sint32 load (const Sint32 idCDC, const string &sName)
 Load an image stored in a CDC file.
Sint32 loadFromBuffer (const void *pBuffer, Sint32 iSize, const string &sName)
 Load an image (BMP or PNG formats) stored on a memory buffer.
Sint32 remove (Sint32 idCDC, const string &sName)
 Remove an image stored in a CDC file.
bool exist (Sint32 idCDC, const string &sName)
 Check if an image is stored in a CDC file.
bool exist (const string &sCDCFile, const string &sName)
 Check if an image is stored in a CDC file.

Member Function Documentation

◆ info()

bool CRM64Pro::ImageMgr::info ( Sint32 iMode = 0)
override

Request Image Manager information.

Writes information to the default log.

Parameters
iMode-1 to display only manager information. 0 (default) to display manager and all objects. Specific object ID to display manager and only that object.
Returns
true on success, or false on failure.

◆ create()

Sint32 CRM64Pro::ImageMgr::create ( const string & sName,
Uint32 iVersion = 10 )
override

Creates a new image.

Creates an empty image (no source surface). Use Image::assignSurface() to assign the source surface.

Parameters
sNameThe image name (e.g. 'myImage'). Must be unique, max 64 characters (truncated if longer). Cannot start with '#'.
iVersionImage version. 10 means v1.0 (only version supported). Default v1.0.
Returns
greater than 0 on success (the Image id) or a negative error code on failure.
Note
Returns error if name already exists.

◆ close()

bool CRM64Pro::ImageMgr::close ( Sint32 idImg)
override

Close and destroy an image.

This method can only close images belonging to the default owner (ImageMgr).

Parameters
idImg0 for closing all images, or specific Image id. Stand-alone and child images can be closed; parent images cannot while they have children.
Returns
true on success or false on failure.
Note
Unclosed images are automatically closed when the GDK terminates.

◆ getCount()

Sint32 CRM64Pro::ImageMgr::getCount ( ) const
override

Get number of loaded objects.

Returns
the number of images.

◆ setName()

Sint32 CRM64Pro::ImageMgr::setName ( Sint32 idImg,
const string & sName )
override

Change the object name.

Parameters
idImgImage id.
sNameThe image name (e.g. 'myImage'). Must be unique, max 64 characters (truncated if longer). Cannot start with '#'.
Returns
0 on success, or a negative error code on failure.

◆ closeEx()

bool CRM64Pro::ImageMgr::closeEx ( Sint32 idImg,
Uint32 iOwner )

Close and destroy an image.

Can close images belonging to any owner, but owner must be provided as a security check.

Parameters
idImg0 for closing all images, or specific Image id. Stand-alone and child images can be closed; parent images cannot while they have children.
iOwnerOwner of the image.
Returns
true on success or false on failure.
Note
Unclosed images are automatically closed when the GDK terminates.

◆ get()

Image * CRM64Pro::ImageMgr::get ( Sint32 idImg)

Get a pointer to the image using its handler.

Parameters
idImgImage id.
Returns
nullptr the image was not found.
A pointer to the image object.

◆ duplicate()

Sint32 CRM64Pro::ImageMgr::duplicate ( Sint32 idImg,
const string & sName )

Duplicate an image creating a new, identical and independent one.

Parameters
idImgImage id to be duplicated.
sNameThe image name (e.g. 'myImage'). Must be unique, max 64 characters (truncated if longer). Cannot start with '#'.
Returns
greater than 0 on success (the Image id) or a negative error code on failure.
Note
Returns error if name already exists. New image is not optimized; call Image::optimize() if needed.

◆ child()

Sint32 CRM64Pro::ImageMgr::child ( Sint32 idImg)

Create a child image dependent on the provided one (the parent).

A child image uses the parent's source surface and textures but can have different attributes. Useful for saving memory.

Parameters
idImgparent Image id. If the provided image is a child, the request is redirected to its parent.
Returns
greater than 0 on success (the Image id) or a negative error code on failure.
Note
The child uses the parent's name.

◆ isBMP()

bool CRM64Pro::ImageMgr::isBMP ( const string & sFile)

Check if the file is a BMP.

Parameters
sFilestring containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.
Returns
true if it is a BMP or false on failure.

◆ isPNG()

bool CRM64Pro::ImageMgr::isPNG ( const string & sFile)

Check if the file is a PNG.

Parameters
sFilestring containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.
Returns
true if it is a PNG or false on failure.

◆ loadFromFile()

Sint32 CRM64Pro::ImageMgr::loadFromFile ( const string & sFile,
const string & sName = "" )

Load an image from an external file (BMP or PNG formats).

Parameters
sFilestring containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.
sNamethe image object name. If empty (default), uses filename without extension. Must be unique, max 64 characters.
Returns
greater than 0 on success (the Image id) or a negative error code on failure.

◆ load() [1/2]

Sint32 CRM64Pro::ImageMgr::load ( const string & sCDCFile,
const string & sName )

Load an image stored in a CDC file.

Parameters
sCDCFilestring containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.
sNamestring with the image name (max 64 characters). If already exists, creates a child instead.
Returns
greater than 0 on success (the Image id) or a negative error code on failure.

◆ load() [2/2]

Sint32 CRM64Pro::ImageMgr::load ( const Sint32 idCDC,
const string & sName )

Load an image stored in a CDC file.

Parameters
idCDCCDC id.
sNamestring with the image name (max 64 characters). If already exists, creates a child instead.
Returns
greater than 0 on success (the Image id) or a negative error code on failure.

◆ loadFromBuffer()

Sint32 CRM64Pro::ImageMgr::loadFromBuffer ( const void * pBuffer,
Sint32 iSize,
const string & sName )

Load an image (BMP or PNG formats) stored on a memory buffer.

Parameters
pBufferbuffer pointer containing the BMP or PNG raw data.
iSizesize in bytes of the buffer.
sNamethe image object name. Must be unique, max 64 characters.
Returns
greater than 0 on success (the Image id) or a negative error code on failure.

◆ remove()

Sint32 CRM64Pro::ImageMgr::remove ( Sint32 idCDC,
const string & sName )

Remove an image stored in a CDC file.

Parameters
idCDCCDC id.
sNamestring with the image name (maximum size of 64 characters).
Returns
greater than 0 on success, or a negative error code on failure.
Note
The image must be closed before trying to remove it from the CDC.

◆ exist() [1/2]

bool CRM64Pro::ImageMgr::exist ( Sint32 idCDC,
const string & sName )

Check if an image is stored in a CDC file.

Parameters
idCDCCDC id.
sNamestring with the image name (maximum size of 64 characters).
Returns
true on success(it exists) or false on failure (it does not exist).
Note
It is normally used for checking if an image is present without throwing any error.

◆ exist() [2/2]

bool CRM64Pro::ImageMgr::exist ( const string & sCDCFile,
const string & sName )

Check if an image is stored in a CDC file.

Parameters
sCDCFilePath to the CDC archive file.
sNamestring with the image name (maximum size of 64 characters).
Returns
true on success(it exists) or false on failure (it does not exist).
Note
It is normally used for checking if an image is present without throwing any error.