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

Loading...
Searching...
No Matches
Scene Layer Image
Scene modules » Scene Layer

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

Get the layer type.

Returns
  SLT_IMAGE.

Implements CRM64Pro::SceneLayer.

## ◆ update()

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

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

Parameters

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

Render image layer content.

Parameters

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

  iLayer | Selected layer ID (from 1 to number of allocated layers), or -1 to use the first empty slot or append a new slot.
  sFile | string containing [directory]+filename+[BMP or PNG extension]. Directory separators '\' and '/' are supported.
  sLayerName | layer name. If empty, file name is used.
  iTileSizeX | Tile width to divide image. 0 creates an imagelayer.
  iTileSizeY | Tile height to divide image. 0 creates an imagelayer.
  fMaxDevPercentage | 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 | 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

  iLayer | Selected layer ID (from 1 to number of allocated layers), or -1 to use the first empty slot or append a new slot.
  idImg | Image ID to import.
  sLayerName | layer name. If empty, image name is used.
  iTileSizeX | Tile width to divide image. 0 creates an imagelayer.
  iTileSizeY | Tile height to divide image. 0 creates an imagelayer.
  fMaxDevPercentage | 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 | iLayer,
|  | const string & | sFile )

Export a layer to an external PNG image.

Parameters

  iLayer | 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 | iLayer,
|  | Sint32 | idImg )

Export a layer to an image.

Parameters

  iLayer | 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.