Class TCastleImagePersistent
Unit
Declaration
type TCastleImagePersistent = class(TPersistent)
Description
Image that can be easily loaded from URL (possibly reusing a cache), drawn, and serialized to/from file.
Wraps TEncodedImage (image data in normal memory, usually one of TCastleImage descendants) and TDrawableImage (image data on GPU).
Adds a cache of TDrawableImage underneath (which can be turned off, see Cache).
Can be serialized (so you can use this as a SubComponent in various TCastleUserInterface descendants that want to expose some image).
Hierarchy
- TObject
- TPersistent
- TCastleImagePersistent
Overview
Methods
procedure DoChange; virtual; |
|
constructor Create; |
|
destructor Destroy; override; |
|
procedure ImageChanged; |
|
function Width: Cardinal; |
|
function Height: Cardinal; |
|
function Empty: Boolean; |
|
procedure Draw(const ScreenRectangle: TFloatRectangle); |
Properties
property OnChange: TNotifyEvent read FOnChange write FOnChange; |
|
property Image: TEncodedImage read GetImage write SetImage; |
|
property OwnsImage: boolean read GetOwnsImage write SetOwnsImage default true; |
|
property DrawableImage: TDrawableImage read FDrawableImage write SetDrawableImage; |
|
property OwnsDrawableImage: boolean read FOwnsDrawableImage write FOwnsDrawableImage default true; |
|
property RotationCenter: TVector2 read FRotationCenter write SetRotationCenter; |
|
property ClipLine: TVector3 read FClipLine write SetClipLine; |
|
property CustomShader: TGLSLProgram read FCustomShader write SetCustomShader; |
|
property ScaleCorners: Single
read FScaleCorners write SetScaleCorners default 1; |
|
property Color: TCastleColor read FColor write SetColor; |
|
property InternalVisualizeProtectedSides: Boolean
read FInternalVisualizeProtectedSides write FInternalVisualizeProtectedSides; |
|
property ScaleFromUrl: Single read FScaleFromUrl; |
|
property URL: String read FURL write SetURL; |
|
property AlphaChannel: TAutoAlphaChannel
read FAlphaChannel write SetAlphaChannel default acAuto; |
|
property Cache: Boolean read FCache write SetCache default true; |
|
property SmoothScaling: boolean
read FSmoothScaling write SetSmoothScaling default true; |
|
property Rotation: Single read FRotation write SetRotation default 0; |
|
property Clip: boolean read FClip write SetClip default false; |
|
property FlipHorizontal: Boolean read FFlipHorizontal write SetFlipHorizontal
default false; |
|
property FlipVertical: Boolean read FFlipVertical write SetFlipVertical
default false; |
|
property ProtectedSides: TBorder read FProtectedSides; |
|
property ColorPersistent: TCastleColorPersistent read FColorPersistent ; |
|
property ClipLinePersistent: TCastleVector3Persistent read FClipLinePersistent ; |
|
property RotationCenterPersistent: TCastleVector2Persistent read FRotationCenterPersistent ; |
Description
Methods
procedure DoChange; virtual; |
|
constructor Create; |
|
destructor Destroy; override; |
|
procedure ImageChanged; |
|
If you modified the Image contents (colors, or maybe even image size) you need to call this. |
function Width: Cardinal; |
|
function Height: Cardinal; |
|
function Empty: Boolean; |
|
procedure Draw(const ScreenRectangle: TFloatRectangle); |
|
Draw the image in given screen area. |
Properties
property OnChange: TNotifyEvent read FOnChange write FOnChange; |
|
Reserved for parent UI control to listen for changes. |
property Image: TEncodedImage read GetImage write SetImage; |
|
Image contents, or Note that by default the TEncodedImage instance assigned here is owned by this component (see OwnsImage). So if you set this property to your custom TEncodedImage instance you should leave memory management of this instance to this component. You can either create a copy by TEncodedImage.MakeCopy if you want to give here only a copy, or you can change OwnsImage to It is allowed to modify the contents or even size of this image. Just make sure to call ImageChanged after the modifications are done to update the rendered image (and possibly the UI control size, e.g. in case TCastleImageControl uses this TCastleImagePersistent, and TCastleImageControl.Stretch=false). |
property OwnsImage: boolean read GetOwnsImage write SetOwnsImage default true; |
|
Whether the memory management of assigned Image is automatic. See Image documentation for details. Note that setting URL changes Image, and changes Note that setting DrawableImage changes Image too, and changes |
property DrawableImage: TDrawableImage read FDrawableImage write SetDrawableImage; |
|
Image used for drawing. Never Usually you do not want to change this property. You can change URL, or Image, and the drawable image will reflect this. But there are good use-cases to change the DrawableImage directly: e.g. you can use fast image-to-image drawing using TDrawableImage.DrawFrom. Or you can set a new instance of TDrawableImage here. Be sure to adjust OwnsDrawableImage as needed. Note that when OpenGL(ES) context is lost and recreated (which can happen at any moment on mobile devices), the contents of this are reinitialized from Image. |
property OwnsDrawableImage: boolean read FOwnsDrawableImage write FOwnsDrawableImage default true; |
|
Whether we should automatically free the DrawableImage instance. Note that this is restored to |
property RotationCenter: TVector2 read FRotationCenter write SetRotationCenter; |
|
Center of rotation. Expressed as a fraction within the drawn ScreenRectangle, (0,0) means bottom-left corner, (1,1) means top-right corner. Default (0.5,0.5). |
property ClipLine: TVector3 read FClipLine write SetClipLine; |
|
If Clip, this is the line equation used to determine whether we clip the given pixel. Given a line (A, B, C) and pixel (x, y), the pixel is clipped (rejected) if The equation is calculated in the coordinates in which image X, Y spans from (0, 0) (bottom-left) to (1, 1) (top-right). For example |
property CustomShader: TGLSLProgram read FCustomShader write SetCustomShader; |
|
Custom GLSL shading code. See TDrawableImage.CustomShader for explanation. |
property ScaleCorners: Single
read FScaleCorners write SetScaleCorners default 1; |
|
In case of TDrawableImage.Draw3x3 the corners on screen are scaled by this amount. This is especially useful for UI scaling, see TCastleContainer.UIScaling and TCastleUserInterface.UIScale. |
property Color: TCastleColor read FColor write SetColor; |
|
Color tint of the image. This simply multiplies the image RGBA components, just like TDrawableImage.Color. By default this is opaque white, which means that image colors are unchanged. |
property InternalVisualizeProtectedSides: Boolean
read FInternalVisualizeProtectedSides write FInternalVisualizeProtectedSides; |
|
property ScaleFromUrl: Single read FScaleFromUrl; |
|
property URL: String read FURL write SetURL; |
|
Changing this also changes Image and DrawableImage. OwnsDrawableImage and OwnsImage always change to |
property AlphaChannel: TAutoAlphaChannel
read FAlphaChannel write SetAlphaChannel default acAuto; |
|
How to treat alpha channel of the assigned image. By default, this is acAuto, which means that image contents together with current Color determine how the alpha of image is treated (opaque, alpha test, alpha blending). Set this to force specific treatment. |
property Cache: Boolean read FCache write SetCache default true; |
|
If The limitation is that you shouldn't change the Image contents (e.g. changing TCastleImage.Colors) or DrawableImage contents (e.g. by using TDrawableImage.RenderToImageBegin), or you will change all shared images. Note that if you assign DrawableImage (instead of URL) and we should free it ourselves (because OwnsDrawableImage) then we assume it was not loaded through our internal cache. Note that if you assign Image (instead of URL) then we assume it was not loaded through our internal cache. (We make sure to detach the TDrawableImage from cache too, in this case.) Changing this property reloads the image (if some URL was set). |
property SmoothScaling: boolean
read FSmoothScaling write SetSmoothScaling default true; |
|
Is the image scaling mode smooth (bilinear filtering) or not (nearest-pixel filtering). See TDrawableImage.SmoothScaling. |
property Rotation: Single read FRotation write SetRotation default 0; |
|
Rotation in radians. Default value 0. |
property Clip: boolean read FClip write SetClip default false; |
|
|
property FlipHorizontal: Boolean read FFlipHorizontal write SetFlipHorizontal
default false; |
|
property FlipVertical: Boolean read FFlipVertical write SetFlipVertical
default false; |
|
property ProtectedSides: TBorder read FProtectedSides; |
|
Corners and edges of the image that are protected from scaling distortion when TCastleImageControl.Stretch is used. We use the 9-slicing algorithm, described at TDrawableImage.Draw3x3 and https://en.wikipedia.org/wiki/9-slice_scaling to scale the image. |
property ColorPersistent: TCastleColorPersistent read FColorPersistent ; |
|
Color that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write Color directly. See also
|
property ClipLinePersistent: TCastleVector3Persistent read FClipLinePersistent ; |
|
ClipLine that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write ClipLine directly. See also |
property RotationCenterPersistent: TCastleVector2Persistent read FRotationCenterPersistent ; |
|
RotationCenter that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write RotationCenter directly. See also
|
Generated by PasDoc 0.16.0.