Class TEncodedImage
Unit
Declaration
type TEncodedImage = class(TObject)
Description
Abstract class for an image with unspecified, possibly compressed, memory format. Both uncompressed images (TCastleImage) and images compressed for GPU (TGPUCompressedImage) are derived from this base class.
Hierarchy
- TObject
- TEncodedImage
Overview
Fields
FRawPixels: Pointer; |
Methods
destructor Destroy; override; |
|
function Size: Cardinal; virtual; abstract; |
|
function Dimensions: TVector3Cardinal; |
|
function IsEmpty: boolean; |
|
function HasAlpha: boolean; virtual; |
|
function AlphaChannel( const AlphaTolerance: Byte = DefaultAlphaTolerance): TAlphaChannel; virtual; |
|
function Rect: TRectangle; |
|
function CreateCopy: TEncodedImage; virtual; abstract; |
|
procedure FlipVertical; virtual; abstract; |
|
function ToFpImage: TInternalCastleFpImage; virtual; deprecated 'interoperability with FpImage may be dropped in the future'; |
Properties
property Url: String read FUrl write FUrl; |
|
property Width: Cardinal read FWidth; |
|
property Height: Cardinal read FHeight; |
|
property Depth: Cardinal read FDepth; |
|
property RawPixels: Pointer read FRawPixels; |
Description
Fields
FRawPixels: Pointer; |
|
Operate on this by Get/Realloc/FreeMem. It's always freed and nil'ed in destructor. |
Methods
destructor Destroy; override; |
|
This item has no description. |
function Size: Cardinal; virtual; abstract; |
|
Size of image contents in bytes. |
function Dimensions: TVector3Cardinal; |
|
function IsEmpty: boolean; |
|
Is an image empty.
|
function HasAlpha: boolean; virtual; |
|
Does an image have an alpha channel. You may also be interested in the AlphaChannel that can make a distinction between alpha channel for blending and for alpha test. AlphaChannel answers always atNone if Descendants implementors notes: in this class, TCastleImage, this returns |
function AlphaChannel( const AlphaTolerance: Byte = DefaultAlphaTolerance): TAlphaChannel; virtual; |
|
Analyze image contents to determine if, and what kind, of alpha channel it has. This may be a time-consuming operation. When the image has alpha channel and we need to decide whether it's suitable for "alpha test" (only fully opaque or fully transparent pixels) or "alpha blending" (any alpha value makes sense) then this method needs to iterate over image pixels. For this reason, the result of this operation is cached at various levels, e.g. TImageTextureNode and TDrawableImage cache it internally. We determine "alpha test - simple yes/no alpha channel" if all the alpha values (for every pixel) are 0, or 255, or (when AlphaTolerance <> 0) are close to them by AlphaTolerance. So, to be precise, alpha value must be <= AlphaTolerance, or >= 255 - AlphaTolerance. If any alpha value is between [AlphaTolerance + 1, 255 - AlphaTolerance - 1] then we return "alpha blending - full range alpha channel". Note that big values of AlphaTolerance make it easier to quality image as "alpha test - simple yes/no alpha channel". When AlphaTolerance >= 128, all images are treated as "simple yes/no alpha". Usually, you want to keep AlphaTolerance small. Descendants implementors notes: in this class, this simply always returns atNone. For descendants that have alpha channel, implement it, honouring AlphaTolerance as described. |
function Rect: TRectangle; |
|
Rectangle representing the inside of this image. Always (Left,Bottom) are zero, and (Width,Height) correspond to image sizes. |
function CreateCopy: TEncodedImage; virtual; abstract; |
|
Create a new image object that has exactly the same class and the same data (size, pixels) as this image. |
procedure FlipVertical; virtual; abstract; |
|
Mirror image vertically. |
Properties
property Url: String read FUrl write FUrl; |
|
Url from which this image was loaded, if any. |
property Width: Cardinal read FWidth; |
|
This item has no description. |
property Height: Cardinal read FHeight; |
|
This item has no description. |
property Depth: Cardinal read FDepth; |
|
Depth of the image. For 2D images (most common) this is just 1. All images in CastleImages can be potentially 3D, which means they can have Depth > 1. A 3D image is just a 3-dimensional array of pixels, and you can use it e.g. as a texture with 3D texture coordinates. A sample use-cases for 3D textures are:
|
property RawPixels: Pointer read FRawPixels; |
|
Image data. The layout of this memory is defined by descendants. For example, for TCastleImage it's a simple array of pixels (see TCastleImage docs for exact description of the memory layout), for TGPUCompressedImage it's a compressed data for GPU. Note that this may be |
Generated by PasDoc 0.16.0-snapshot.