CRM64Pro GDK v0.19.0
A free cross-platform game development kit built on top of SDL 3.0
Loading...
Searching...
No Matches
Scene Layer Image

Description

Image layer containing a single image for background/foreground display.

Each SceneLayerImage holds a reference to an Image resource and source metadata for save/load operations. Generic layer properties (parallax, opacity, visibility) are managed by Scene.

Classes

class  CRM64Pro::SceneLayerImage
 Image layer containing a single image for background/foreground display. More...

Functions

eSceneLayerType CRM64Pro::SceneLayerImage::getType () const override
 Get the layer type.
Sint32 CRM64Pro::SceneLayerImage::update (Scene *pEngine, SceneLayerContext &rContext) override
 Update image layer logic (minimal, mainly for callbacks).
Sint32 CRM64Pro::SceneLayerImage::render (Scene *pEngine, SceneLayerContext &rContext) override
 Render image layer content.
Sint32 CRM64Pro::SceneLayerImage::getImageID () const
 Get the Image resource ID.
bool CRM64Pro::SceneLayerImage::setImage (Sint32 idImage)
 Set the Image resource.
void CRM64Pro::SceneLayerImage::getSource (string &sFile, string &sArchive, string &sPath, eSceneStorageMode &eMode) const
 Get source file information for save/load operations.
void CRM64Pro::SceneLayerImage::setSource (const string &sFile, const string &sArchive, const string &sPath, eSceneStorageMode eMode)
 Set source file information for save/load operations.
float CRM64Pro::SceneLayerImage::getTotalWidth () const override
 Get layer total width in pixels.
float CRM64Pro::SceneLayerImage::getTotalHeight () const override
 Get layer total height in pixels.
Sint32 CRM64Pro::Scene::importLayerFromFile (Sint32 iLayer, const string &sFile, const string &sLayerName, Sint32 iTileSizeX, Sint32 iTileSizeY, float fMaxDevPercentage=100.0, Sint32 iCK=-1)
 Import an image file (BMP or PNG) into a layer.
Sint32 CRM64Pro::Scene::importLayerFromImage (Sint32 iLayer, Sint32 idImg, const string &sLayerName, Sint32 iTileSizeX, Sint32 iTileSizeY, float fMaxDevPercentage=100.0, Sint32 iCK=-1)
 Import an image into a layer.
Sint32 CRM64Pro::Scene::exportLayerToFile (Sint32 iLayer, const string &sFile)
 Export a layer to an external PNG image.
Sint32 CRM64Pro::Scene::exportLayerToImage (Sint32 iLayer, Sint32 idImg)
 Export a layer to an image.

Function Documentation

◆ getType()

eSceneLayerType CRM64Pro::SceneLayerImage::getType ( ) const
overridevirtual

Get the layer type.

Returns
SLT_IMAGE.

Implements CRM64Pro::SceneLayer.

◆ update()

Sint32 CRM64Pro::SceneLayerImage::update ( Scene * pEngine,
SceneLayerContext & rContext )
overrideprotectedvirtual

Update image layer logic (minimal, mainly for callbacks).

Parameters
pEnginePointer to the Scene instance.
rContextLayer context structure containing update state.
Returns
0 on success, or a negative error code on failure.

Implements CRM64Pro::SceneLayer.

◆ render()

Sint32 CRM64Pro::SceneLayerImage::render ( Scene * pEngine,
SceneLayerContext & rContext )
overrideprotectedvirtual

Render image layer content.

Parameters
pEnginePointer to the Scene instance.
rContextLayer context structure containing render state.
Returns
0 on success, or a negative error code on failure.

Implements CRM64Pro::SceneLayer.

◆ getImageID()

Sint32 CRM64Pro::SceneLayerImage::getImageID ( ) const

Get the Image resource ID.

Returns
Image resource ID, or 0 if no image is assigned.

◆ setImage()

bool CRM64Pro::SceneLayerImage::setImage ( Sint32 idImage)

Set the Image resource.

Transfers exclusive ownership of a stand-alone Image resource to this layer.

Parameters
idImageValid Image resource ID owned by ImageMgr.
Returns
true on success, or false if the image is invalid, has no surface, or is already owned.
Note
On success, the caller must not close or transfer the image. Replacing it closes the previous image.
Replacing the image resets its source metadata to internal storage; call setSource() to provide external source information.

◆ getSource()

void CRM64Pro::SceneLayerImage::getSource ( string & sFile,
string & sArchive,
string & sPath,
eSceneStorageMode & eMode ) const

Get source file information for save/load operations.

Parameters
sFileOutput filename.
sArchiveOutput CDC archive name (empty if not from CDC).
sPathOutput directory path.
eModeOutput storage mode.

◆ setSource()

void CRM64Pro::SceneLayerImage::setSource ( const string & sFile,
const string & sArchive,
const string & sPath,
eSceneStorageMode eMode )

Set source file information for save/load operations.

Parameters
sFileFilename.
sArchiveCDC archive name (empty if not from CDC).
sPathDirectory path.
eModeStorage mode.

◆ getTotalWidth()

float CRM64Pro::SceneLayerImage::getTotalWidth ( ) const
overridevirtual

Get layer total width in pixels.

Returns
Width of the image, or 0 if no image assigned.

Reimplemented from CRM64Pro::SceneLayer.

◆ getTotalHeight()

float CRM64Pro::SceneLayerImage::getTotalHeight ( ) const
overridevirtual

Get layer total height in pixels.

Returns
Height of the image, or 0 if no image assigned.

Reimplemented from CRM64Pro::SceneLayer.

◆ importLayerFromFile()

Sint32 CRM64Pro::Scene::importLayerFromFile ( Sint32 iLayer,
const string & sFile,
const string & sLayerName,
Sint32 iTileSizeX,
Sint32 iTileSizeY,
float fMaxDevPercentage = 100.0,
Sint32 iCK = -1 )

Import an image file (BMP or PNG) into a layer.

Creates a new base tile layer and tileset. Selected layer must be empty (no tile layer). Level name is used for layer and tileset names.

Parameters
iLayerSelected layer ID (from 1 to number of allocated layers), or -1 to use the first empty slot or append a new slot.
sFilestring containing [directory]+filename+[BMP or PNG extension]. Directory separators '\' and '/' are supported.
sLayerNamelayer name. If empty, file name is used.
iTileSizeXTile width to divide image. 0 creates an imagelayer.
iTileSizeYTile height to divide image. 0 creates an imagelayer.
fMaxDevPercentagePercentage of differing pixels before tile is unique. Default 100% gets only identical tiles.
iCKFor images without alpha, this RGB color is transparent. Default -1 (disabled).
Returns
0 on success, or a negative error code on failure.
Note
Tileset has proportional size to tile sizes. Sizes > 4096 trigger a warning (some backends don't support them).

◆ importLayerFromImage()

Sint32 CRM64Pro::Scene::importLayerFromImage ( Sint32 iLayer,
Sint32 idImg,
const string & sLayerName,
Sint32 iTileSizeX,
Sint32 iTileSizeY,
float fMaxDevPercentage = 100.0,
Sint32 iCK = -1 )

Import an image into a layer.

Creates a new base tile layer and tileset. Selected layer must be empty (no tile layer). Level name is used for layer and tileset names.

Parameters
iLayerSelected layer ID (from 1 to number of allocated layers), or -1 to use the first empty slot or append a new slot.
idImgImage ID to import.
sLayerNamelayer name. If empty, image name is used.
iTileSizeXTile width to divide image. 0 creates an imagelayer.
iTileSizeYTile height to divide image. 0 creates an imagelayer.
fMaxDevPercentagePercentage of differing pixels before tile is unique. Default 100% gets only identical tiles.
iCKFor images without alpha, this RGB color is transparent. Default -1 (disabled).
Returns
0 on success, or a negative error code on failure.
Note
Tileset has proportional size to tile sizes. Sizes > 4096 trigger a warning (some backends don't support them).

◆ exportLayerToFile()

Sint32 CRM64Pro::Scene::exportLayerToFile ( Sint32 iLayer,
const string & sFile )

Export a layer to an external PNG image.

Parameters
iLayerLayer to export, from 1 to number of allocated layers or 0 to export all layers. The layer must have ::SLF_RENDER feature enabled.
sFilestring containing the [directory]+filename+[extension].
Returns
0 on success, or a negative error code on failure.

◆ exportLayerToImage()

Sint32 CRM64Pro::Scene::exportLayerToImage ( Sint32 iLayer,
Sint32 idImg )

Export a layer to an image.

Parameters
iLayerLayer to export, from 1 to number of allocated layers or 0 to export all layers. The layer must have ::SLF_RENDER feature enabled.
idImgImage ID. The image should not have assigned any surface.
Returns
0 on success, or a negative error code on failure.