Class TAtlasImage

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TAtlasImage = class(TCustomCanvasImage)

Description

Atlas image may contain one or more textures and multiple regions, which can be selected when rendering on canvas.

Hierarchy

Overview

Methods

Public constructor Create(const ADevice: TCustomDevice; const ASubscribedTextures: Boolean = True);
Public function DeviceRestore: Boolean; virtual;
Public function IndexOfTexture(const Texture: TCustomLockableTexture): Integer;
Public function InsertTexture(const InitWidth, InitHeight: Integer): TCustomLockableTexture; overload;
Public function InsertTexture: Integer; overload;
Public function LoadFromAsset(const AssetName: StdString; const AlphaFormatRequest: TAlphaFormatRequest = TAlphaFormatRequest.DontCare): Boolean;
Public function LoadFromFile(const FileName: StdString; const AlphaFormatRequest: TAlphaFormatRequest = TAlphaFormatRequest.DontCare): Boolean;
Public function LoadFromStream(const Extension: StdString; const Stream: TStream; const AlphaFormatRequest: TAlphaFormatRequest = TAlphaFormatRequest.DontCare): Boolean;
Protected function GetRegion(const Index: Integer): TIntRectList.PItem; override;
Protected function GetTexture(const Index: Integer): TCustomBaseTexture; override;
Protected function GetTextureCount: Integer; override;
Public procedure ClearTextures;
Public procedure DeviceRelease; virtual;
Public procedure RemoveTexture(const Index: Integer);
Public procedure SetupRegionPatterns(const PatternSize: TPoint2i; VisibleSize: TPoint2i; const PatternCount: Integer = 0); overload;
Public procedure SetupRegionPatterns(const PatternSize: TPoint2i); overload; inline;

Properties

Public property Device: TCustomDevice read FDevice;
Public property DynamicImage: Boolean read FDynamicImage write FDynamicImage;
Public property MipMapping: Boolean read FMipMapping write FMipMapping;
Public property Name: StdString read FName write FName;
Public property PixelFormat: TPixelFormat read FPixelFormat write FPixelFormat;
Public property PremultipliedAlpha: Boolean read FPremultipliedAlpha write FPremultipliedAlpha;
Public property Regions: TIntRectList read FRegions;
Public property SubscribedTextures: Boolean read FSubscribedTextures;
Public property Texture[constIndex:Integer]: TCustomLockableTexture read GetLockableTexture;
Public property TextureCount: Integer read GetTextureCount;

Description

Methods

Public constructor Create(const ADevice: TCustomDevice; const ASubscribedTextures: Boolean = True);

Creates new instance of TAtlasImage class bound to the specified device. ASubscribedTextures indicates whether the textures contained in this image should be subscribed to handle "lost device" events. If this image is part of TAtlasImages list, which provides its own notification events regarding device status, then ASubscribedTextures should be set to False.

Public function DeviceRestore: Boolean; virtual;

Restores the image after its texture surfaces have been lost (that is, after DeviceRelease call). Note that this method should only be called when ASubscribedTextures has been set to False during creation.

Public function IndexOfTexture(const Texture: TCustomLockableTexture): Integer;

Returns index of the specified texture in the list. If no such texture is found, -1 is returned.

Public function InsertTexture(const InitWidth, InitHeight: Integer): TCustomLockableTexture; overload;

Inserts a new texture to the list of existing textures and tries to initialize with the given width and height, returning its index. If initialization fails, then Nil is returned and the texture is not added to the list.

Public function InsertTexture: Integer; overload;

Inserts a new texture (not initialized) to the list of existing textures and returns its index.

Public function LoadFromAsset(const AssetName: StdString; const AlphaFormatRequest: TAlphaFormatRequest = TAlphaFormatRequest.DontCare): Boolean;

Loads image with the specified file name from /assets sub-folder on Android platform. This uses image format manager reference from the associated device. Returns True when succeeded and False otherwise. The method is unsupported on non-Android platforms.

Public function LoadFromFile(const FileName: StdString; const AlphaFormatRequest: TAlphaFormatRequest = TAlphaFormatRequest.DontCare): Boolean;

Loads image with the specified file name from disk. This uses image format manager reference from the associated device. Returns True when succeeded and False otherwise.

Public function LoadFromStream(const Extension: StdString; const Stream: TStream; const AlphaFormatRequest: TAlphaFormatRequest = TAlphaFormatRequest.DontCare): Boolean;

Loads image with format corresponding to the given extension from the stream. This uses image format manager reference from the associated device. Returns True when succeeded and False otherwise.

Protected function GetRegion(const Index: Integer): TIntRectList.PItem; override;

Retrieves the region specified by its index with information regarding texture number and margins. If the index is outside of valid range, Nil is returned.

Protected function GetTexture(const Index: Integer): TCustomBaseTexture; override;

Provides access to individual textures in the image based on the specified index. If the index is outside of valid range, Nil is returned.

Protected function GetTextureCount: Integer; override;

Returns the number of textures present in the image.

Public procedure ClearTextures;

Removes any existing textures from the list.

Public procedure DeviceRelease; virtual;

Releases the image's texture surfaces when the device has been lost. Note that this method should only be called when ASubscribedTextures has been set to False during creation.

Public procedure RemoveTexture(const Index: Integer);

Removes texture with the specified index from the list.

Public procedure SetupRegionPatterns(const PatternSize: TPoint2i; VisibleSize: TPoint2i; const PatternCount: Integer = 0); overload;

Configures the list of regions as if they were rectangular patterns in the image tiled horizontally in series of rows and columns. This fills Regions with new data.

Parameters
PatternSize
Defines the size of individual pattern.
VisibleSize
Defines the "visible" size inside each individual pattern. This should either match PatternSize or be smaller.
PatternCount
Determines the total number of patterns inside the image. The total number of resulting regions will be equal or smaller than this number.
Public procedure SetupRegionPatterns(const PatternSize: TPoint2i); overload; inline;

Configures the list of regions as if they were rectangular patterns in the image tiled horizontally in series of rows and columns. This fills Regions with new data.

Properties

Public property Device: TCustomDevice read FDevice;

The device to which this image is bound to.

Public property DynamicImage: Boolean read FDynamicImage write FDynamicImage;

Determines whether this image requires frequent access to its pixel data. If this parameter is set to True, dynamic textures will be used, where pixel data can be updated frequently. This should be used when image pixels need to be updated at least once per frame.

Public property MipMapping: Boolean read FMipMapping write FMipMapping;

Determines whether the image should contain mipmap data. This can increase memory consumption and slow down the loading of images, but produces better visual results when the image is shrunk to smaller sizes.

Public property Name: StdString read FName write FName;

Unique name of the image by which it can be referenced in TAtlasImages list.

Public property PixelFormat: TPixelFormat read FPixelFormat write FPixelFormat;

The pixel format that will be used in all image's textures. This parameter is merely a hint and different format may be used in the textures, depending on hardware support; if this format is not supported, usually the closest format will be chosen in textures. When loading pixel data, the conversion will be done automatically, if the texture format does not match the stored pixel format.

Public property PremultipliedAlpha: Boolean read FPremultipliedAlpha write FPremultipliedAlpha;

Indicates whether the pixels in this image have premultiplied or non-premultiplied alpha. This does not affect the actual pixels, it is merely a hint for rendering canvas.

Public property Regions: TIntRectList read FRegions;

This list contains rectangles (with texture number stored as extra pointer value) that define individual sub-images located on one or several textures.

Public property SubscribedTextures: Boolean read FSubscribedTextures;

Indicates whether this class has textures subscribed to device events, handling scenarios such as "device lost". If this is set to False, likely the handling is provided by parent list class such as TAtlasImages through use of DeviceRestore and DeviceRelease events.

Public property Texture[constIndex:Integer]: TCustomLockableTexture read GetLockableTexture;

Provides access to each texture present in the image by its index. If the index is specified outside of valid range, then Nil is returned.

Public property TextureCount: Integer read GetTextureCount;

Total number of textures present in this image.


Copyright © 2000 - 2017 Yuriy Kotsarenko. Help files generated by PasDoc.