  Platform eXtended Library (PXL)Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers |
Class TBitmap
Unit
PXL.Bitmaps
Declaration
type TBitmap = class(TCustomCanvasImage)
Description
High-level bitmap that contains image data with multiple storage options (e.g. system, texture, etc.) and has canvas so it can be drawn into. Bitmap operations such as resizing or storage change attempts to preserve existing data as much as possible. In contrast to many other hardware-assisted components in the framework, the methods of this class return no result type but raise exceptions when issues arise.
Hierarchy
Overview
Methods
Properties
Description
Methods
 |
constructor Create(const ADevice: TCustomDevice); |
|
Creates new instance of bitmap bound to the specific device.
|
 |
function IsEmpty: Boolean; |
|
Returns True if the bitmap has zero size (in other words, is empty) and False otherwise.
|
 |
function CanvasBeginScene: Boolean; override; |
|
This function is called during TBitmap.Canvas.BeginScene call, which essentially tells bitmap's drawable texture to activate. This may trigger storage range if current storage is not drawable texture.
|
 |
function GetRegion(const Index: Integer): TIntRectList.PItem; override; |
|
Returns region specified by the given index from list of existing regions and Nil if Index is outside of valid range.
|
 |
function GetTexture(const Index: Integer): TCustomBaseTexture; override; |
|
Returns either lockable or drawable texture currently occupied by bitmap. Index should always be zero as bitmap can have only one texture. This may trigger storage change if current storage has no texture support.
|
 |
function GetTextureCount: Integer; override; |
|
Returns number of textures as needed by canvas. In this implementation, this will always return one.
|
 |
procedure Clear; |
|
Clears the bitmap by filling image data with zeros.
|
 |
procedure CopyFrom(const Source: TBitmap); |
|
Copies the entire contents of source bitmap to current one. This ensures that current bitmap has the same size as the source. The current pixel format is not changed and if it remains unspecified before this call, it will be set to the default one. This may change bitmap storage for both source and current bitmaps depending on the currently set values to be able to reliably copy image information.
|
 |
procedure LoadFromFile(const FileName: StdString); |
|
Loads bitmap from external file. This may change current pixel format, size and storage type. The function uses image format manager reference provided by the associated device.
|
 |
procedure LoadFromStream(const Stream: TStream; const Extension: StdString); |
|
Loads bitmap from specified stream with image format identified by the given extension. This may change current pixel format, size and storage type. The function uses image format manager reference provided by the associated device.
|
 |
procedure SaveToFile(const FileName: StdString; const Quality: Pointer = nil); |
|
Saves bitmap to external file. This may change current storage type. The function uses image format manager reference provided by the associated device. Quality parameter is a hint that may have different interpretations depending on destination file format, platform and provider; for instance, for JPEG files, on most implementations this is just a typecast integer representing image quality between 0 and 100.
|
 |
procedure SaveToStream(const Stream: TStream; const Extension: StdString; const Quality: Pointer = nil); |
|
Saves bitmap to specified stream with image format identified by the given extension. This may change current storage type. The function uses image format manager reference provided by the associated device. Quality parameter is a hint that may have different interpretations depending on destination file format, platform and provider; for instance, for JPEG files, on most implementations this is just a typecast integer representing image quality between 0 and 100.
|
 |
procedure SetSize(const NewWidth, NewHeight: Integer); overload; |
|
Changes bitmap width and height to new parameters preserving original data as much as possible.
|
 |
procedure SetSize(const NewSize: TPoint2i); overload; inline; |
|
Changes bitmap size to new value preserving original data as much as possible.
|
 |
procedure CanvasEndScene; override; |
|
This function is called during TBitmap.Canvas.EndScene call, which essentially tells bitmap's drawable texture to deactivate.
|
 |
procedure ChangeStorage(const NewStorage: TBitmapStorage); virtual; |
|
Attempts to change current storage to a new one, preserving the data. If operation fails for some reason, the appropriate exception will be raised.
|
Properties
 |
property Canvas: TCustomCanvas read GetCanvas; |
|
Provides access to bitmap's canvas wrapped in TCustomCanvas, so that bitmap can be rendered into. This changes storage type to TBitmapStorage.Drawable while preserving image data.
|
 |
property Device: TCustomDevice read FDevice; |
|
Reference to the device class to which this bitmap is bound to.
|
 |
property Height: Integer read FHeight write SetHeight; |
|
Height of bitmap in pixels. Changing this preserves image contents as much as possible.
|
 |
property PixelFormat: TPixelFormat read FPixelFormat write SetPixelFormat; |
|
Determines the pixel format in which to store bitmap's pixels. Changing this preserves image contents as much as possible.
|
 |
property Regions: TIntRectList read FRegions; |
|
This list contains a list of rectangles that define sub-images (also know as "patterns" or "tiles") located on this bitmap. When drawing the current bitmap to canvas, there are methods that can take region number as parameter, therefore facilitating use of image atlases or tiles.
|
 |
property Size: TPoint2i read GetSize write SetSize; |
|
Size of bitmap in pixels. Changing this preserves image contents as much as possible.
|
 |
property Storage: TBitmapStorage read FStorage write ChangeStorage; |
|
Storage type currently occupied by bitmap. Changing this to a different value may create new type of resources, while releasing others, but the image data is preserved. Many operations may automatically change storage type depending on context, so this should be changed manually only when doing so can improve performance (for example, to start immediately with drawable texture instead of going through system/lockable stages).
|
 |
property Surface: TPixelSurface read GetCurrentSurface; |
|
Provides access to image data wrapped in TPixelSurface for direct pixel access. This changes storage type to TBitmapStorage.System while preserving image data.
|
 |
property Texture: TCustomBaseTexture read GetCurrentTexture; |
|
Provides access to image data wrapped in TCustomBaseTexture, so it can be used for rendering. If current storage type is system (which has no texture), this will change storage type to TBitmapStorage.Lockable.
|
 |
property Width: Integer read FWidth write SetWidth; |
|
Width of bitmap in pixels. Changing this preserves image contents as much as possible.
|
Copyright © 2000 - 2017 Yuriy Kotsarenko. Help files generated by PasDoc.
|