| CRM64Pro GDK v0.17.0 A free cross-platform game development kit built on top of SDL 3.0

Loading...
Searching...
No Matches
Scene LayerImage
Scene module » Scene Layer base

## 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

  sName | Layer name.

## ◆ getType()

eSceneLayerType CRM64Pro::SceneLayerImage::getType | ( |  | ) | const
| override virtual

Get the layer type.

Returns
  SLT_IMAGE.

Implements CRM64Pro::SceneLayer.

## ◆ update()

Sint32 CRM64Pro::SceneLayerImage::update | ( | Scene * | pEngine,
|  | SceneLayerContext & | context )
| override protected virtual

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

Parameters

  pEngine | Pointer to the Scene instance.
  context | Layer 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 )
| override protected virtual

Render image layer content.

Parameters

  pEngine | Pointer to the Scene instance.
  context | Layer 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

  idImage | Valid 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

  sFile | Output filename.
  sArchive | Output CDC archive name (empty if not from CDC).
  sPath | Output directory path.
  eMode | Output 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

  sFile | Filename.
  sArchive | CDC archive name (empty if not from CDC).
  sPath | Directory path.
  eMode | Storage mode.

## ◆ getTotalWidth()

float CRM64Pro::SceneLayerImage::getTotalWidth | ( |  | ) | const
| override virtual

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
| override virtual

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

  layer | Selected layer ID (from 1 to number of allocated layers).
  sFile | string containing [directory]+filename+[BMP or PNG extension]. Directory separators '\' and '/' are supported.
  sLayerName | layer name. If empty, file name is used.
  tileSizeX | Tile width to divide image. 0 creates an imagelayer.
  tileSizeY | Tile height to divide image. 0 creates an imagelayer.
  maxDevPercentage | Percentage of differing pixels before tile is unique. Default 100% gets only identical tiles.
  iCK | For 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

  layer | Selected layer ID (from 1 to number of allocated layers).
  idImg | Image ID to import.
  sLayerName | layer name. If empty, image name is used.
  tileSizeX | Tile width to divide image. 0 creates an imagelayer.
  tileSizeY | Tile height to divide image. 0 creates an imagelayer.
  maxDevPercentage | Percentage of differing pixels before tile is unique. Default 100% gets only identical tiles.
  iCK | For 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

  layer | Layer to export, from 1 to number of allocated layers or 0 to export all layers. The layer must have ::SLF_RENDER feature enabled.
  sFile | string 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

  layer | Layer to export, from 1 to number of allocated layers or 0 to export all layers. The layer must have ::SLF_RENDER feature enabled.
  idImg | Image ID. The image should not have assigned any surface.

Returns
  0 on success, or a negative error code on failure.