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

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

 CRM64Pro::SceneLayerImage::SceneLayerImage (const string &sName)
 Constructor.
eSceneLayerType CRM64Pro::SceneLayerImage::getType () const override
 Get the layer type.
Sint32 CRM64Pro::SceneLayerImage::update (Scene *pEngine, SceneLayerContext &context) override
 Update image layer logic (minimal, mainly for callbacks).
Sint32 CRM64Pro::SceneLayerImage::render (Scene *pEngine, SceneLayerContext &context) 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 layer, const string &sFile, const string &sLayerName, Sint32 tileSizeX, Sint32 tileSizeY, float maxDevPercentage=100.0, Sint32 iCK=-1)
 Import an image file (BMP or PNG) into a layer.
Sint32 CRM64Pro::Scene::importLayerFromImage (Sint32 layer, Sint32 idImg, const string &sLayerName, Sint32 tileSizeX, Sint32 tileSizeY, float maxDevPercentage=100.0, Sint32 iCK=-1)
 Import an image into a layer.
Sint32 CRM64Pro::Scene::exportLayerToFile (Sint32 layer, const string &sFile)
 Export a layer to an external PNG image.
Sint32 CRM64Pro::Scene::exportLayerToImage (Sint32 layer, Sint32 idImg)
 Export a layer to an image.

Function Documentation

◆ SceneLayerImage()

CRM64Pro::SceneLayerImage::SceneLayerImage ( const string & sName)

Constructor.

Parameters
sNameLayer name.

◆ 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 & context )
overrideprotectedvirtual

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

Parameters
pEnginePointer to the Scene instance.
contextLayer 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 & context )
overrideprotectedvirtual

Render image layer content.

Parameters
pEnginePointer to the Scene instance.
contextLayer 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.

Parameters
idImageValid Image resource ID.
Returns
true on success, or false if idImage is invalid.

◆ 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 layer,
const string & sFile,
const string & sLayerName,
Sint32 tileSizeX,
Sint32 tileSizeY,
float maxDevPercentage = 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
layerSelected layer ID (from 1 to number of allocated layers).
sFilestring containing [directory]+filename+[BMP or PNG extension]. Directory separators '\' and '/' are supported.
sLayerNamelayer name. If empty, file name is used.
tileSizeXTile width to divide image. 0 creates an imagelayer.
tileSizeYTile height to divide image. 0 creates an imagelayer.
maxDevPercentagePercentage 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 layer,
Sint32 idImg,
const string & sLayerName,
Sint32 tileSizeX,
Sint32 tileSizeY,
float maxDevPercentage = 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
layerSelected layer ID (from 1 to number of allocated layers).
idImgImage ID to import.
sLayerNamelayer name. If empty, image name is used.
tileSizeXTile width to divide image. 0 creates an imagelayer.
tileSizeYTile height to divide image. 0 creates an imagelayer.
maxDevPercentagePercentage 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 layer,
const string & sFile )

Export a layer to an external PNG image.

Parameters
layerLayer 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 layer,
Sint32 idImg )

Export a layer to an image.

Parameters
layerLayer 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.