Class TCastleImageControl
Unit
Declaration
type TCastleImageControl = class(TCastleUserInterface)
Description
Image control. Size is automatically adjusted to the image size, if Stretch is False
(default). You should set TCastleImageControl.Left, TCastleImageControl.Bottom properties, and load your image by setting TCastleImageControl.Url property or straight TCastleImageControl.Image.
We automatically use alpha test or alpha blending based on loaded image alpha channel (see TDrawableImage.Alpha). You can influence this by AlphaChannel property.
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleUserInterface
- TCastleImageControl
Overview
Methods
procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); override; |
|
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure Render; override; |
|
procedure GLContextOpen; override; |
|
procedure EditorAllowResize( out ResizeWidth, ResizeHeight: Boolean; out Reason: String); override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
procedure ImageChanged; |
Properties
property Image: TEncodedImage read GetImage write SetImage; |
|
property OwnsImage: boolean read GetOwnsImage write SetOwnsImage default true; |
|
property DrawableImage: TDrawableImage read GetDrawableImage write SetDrawableImage; |
|
property OwnsDrawableImage: boolean read GetOwnsDrawableImage write SetOwnsDrawableImage default true; |
|
property Color: TCastleColor read GetColor write SetColor; |
|
property Corners: TVector4Integer read GetCorners write SetCorners; deprecated 'use ProtectedSides'; |
|
property CenterX: Single read GetCenterX write SetCenterX default 0.5; deprecated 'use RotationCenter'; |
|
property CenterY: Single read GetCenterY write SetCenterY default 0.5; deprecated 'use RotationCenter'; |
|
property RotationCenter: TVector2 read GetRotationCenter write SetRotationCenter; |
|
property ClipLine: TVector3 read GetClipLine write SetClipLine; |
|
property Region: TFloatRectangle read GetRegion write SetRegion; |
|
property CustomShader: TGLSLProgram read GetCustomShader write SetCustomShader; |
|
property Blending: boolean read GetBlending write SetBlending stored false; deprecated 'use AlphaChannel'; |
|
property Proportional: boolean read GetProportional write SetProportional stored false default false; deprecated 'use ProportionalScaling'; |
|
property FileName: string read GetUrl write SetUrl stored false; deprecated 'use Url'; |
|
property Content: TCastleImagePersistent read FContent; |
|
property Url: String read GetUrl write SetUrl stored false; |
|
property AlphaChannel: TAutoAlphaChannel
read GetAlphaChannel write SetAlphaChannel stored false default acAuto; |
|
property SmoothScaling: boolean
read GetSmoothScaling write SetSmoothScaling stored false default true; |
|
property Stretch: boolean read FStretch write SetStretch default false; |
|
property ProportionalScaling: TProportionalScaling
read FProportionalScaling write SetProportionalScaling default psNone; |
|
property Cache: boolean read GetCache write SetCache stored false default true; |
|
property FlipHorizontal: Boolean read GetFlipHorizontal write SetFlipHorizontal
stored false default false; |
|
property FlipVertical: Boolean read GetFlipVertical write SetFlipVertical
stored false default false; |
|
property ProtectedSides: TBorder read GetProtectedSides stored false; |
|
property DetectScaleFromUrl: Boolean
read FDetectScaleFromUrl write SetDetectScaleFromUrl default false; |
|
property Rotation: Single read GetRotation write SetRotation stored false default 0; |
|
property Clip: boolean read GetClip write SetClip stored false default false; |
|
property ColorPersistent: TCastleColorPersistent read FColorPersistent stored false; |
|
property ClipLinePersistent: TCastleVector3Persistent read FClipLinePersistent stored false; |
|
property RotationCenterPersistent: TCastleVector2Persistent read FRotationCenterPersistent stored false; |
|
property RegionPersistent: TFloatRectanglePersistent read FRegionPersistent stored false; |
Description
Methods
procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.PreferredSize. Controls that have a preferred size should override this. By default this contains values derived from Width, WidthFraction, Height, HeightFraction, with Border subtracted. Note that the arguments should be already scaled, i.e. multiplied by UIScale, i.e. expressed in final device pixels. Note that the returned PreferredWidth and PreferredHeight must not include the space for Border. Border size will be added later. |
constructor Create(AOwner: TComponent); override; |
|
This item has no description. |
destructor Destroy; override; |
|
This item has no description. |
procedure Render; override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.Render. Render a control. Called only when Exists and render context is initialized. Do not call this method. It will be automatically called by the engine when needed. It will be called when UI is part of TCastleContainer.Controls list or rendered (e.g. for off-screen rendering) by TCastleContainer.RenderControl. You should only override this method. See https://castle-engine.io/manual_2d_ui_custom_drawn.php for examples what you can put here. You can depend on some OpenGL state being set before calling this method. You can depend on it being set, and you can carelessly change it. This state we set:
Beware that GLSL RenderContext.CurrentProgram has undefined value when this is called. You should always set it, before making direct OpenGL drawing calls (all the engine drawing routines do it already, this is only a concern if you make direct OpenGL / OpenGLES calls). |
procedure GLContextOpen; override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.GLContextOpen. Initialize your OpenGL resources. This is called when OpenGL context of the container is created, or when the control is added to the already existing context. In other words, this is the moment when you can initialize OpenGL resources, like display lists, VBOs, OpenGL texture names, etc. As an exception, this is called regardless of the Exists value. This way a control can prepare it's resources, regardless if it exists now. |
procedure EditorAllowResize( out ResizeWidth, ResizeHeight: Boolean; out Reason: String); override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.EditorAllowResize. Override this to prevent resizing some dimension in CGE editor. |
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
This item has no description. Showing description inherited from TCastleComponent.PropertySections. Section where to show property in the editor. |
procedure ImageChanged; |
|
If you modified the Image contents (colors, or maybe even image size) you need to call this. See also
|
Properties
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). See also
|
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 See also
|
property DrawableImage: TDrawableImage read GetDrawableImage 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. See also
|
property OwnsDrawableImage: boolean read GetOwnsDrawableImage write SetOwnsDrawableImage default true; |
|
Whether we should automatically free the DrawableImage instance. Note that this is restored to See also
|
property Color: TCastleColor read GetColor 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. See also
|
property Corners: TVector4Integer read GetCorners write SetCorners; deprecated 'use ProtectedSides'; |
|
Warning: this symbol is deprecated: use ProtectedSides Corners and edges of the image that are not stretched even when Stretch is used. See TDrawableImage.Draw3x3 for the details how such drawing works. |
property RotationCenter: TVector2 read GetRotationCenter 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). See also
|
property ClipLine: TVector3 read GetClipLine 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 See also
|
property Region: TFloatRectangle read GetRegion write SetRegion; |
|
Image region to which we should limit the display. Empty (following TFloatRectangle.Empty) means using the whole image. |
property CustomShader: TGLSLProgram read GetCustomShader write SetCustomShader; |
|
Custom GLSL shading code. See TDrawableImage.CustomShader for explanation. See also
|
property Blending: boolean read GetBlending write SetBlending stored false; deprecated 'use AlphaChannel'; |
|
Warning: this symbol is deprecated: use AlphaChannel This item has no description. |
property FileName: string read GetUrl write SetUrl stored false; deprecated 'use Url'; |
|
Warning: this symbol is deprecated: use Url This item has no description. |
property Content: TCastleImagePersistent read FContent; |
|
Image contents to display. |
property Url: String read GetUrl write SetUrl stored false; |
|
URL of the image. Set this to load a new image, you can set to '' to clear the image. See also
|
property AlphaChannel: TAutoAlphaChannel
read GetAlphaChannel write SetAlphaChannel stored false 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. See also
|
property SmoothScaling: boolean
read GetSmoothScaling write SetSmoothScaling stored false default true; |
|
Is the image scaling mode smooth (bilinear filtering) or not (nearest-pixel filtering). See TDrawableImage.SmoothScaling. See also
|
property Stretch: boolean read FStretch write SetStretch default false; |
|
How does the loaded image size affect the size of the image control.
|
property ProportionalScaling: TProportionalScaling
read FProportionalScaling write SetProportionalScaling default psNone; |
|
This item has no description. |
property Cache: boolean read GetCache write SetCache stored false default true; |
|
If See also
|
property FlipHorizontal: Boolean read GetFlipHorizontal write SetFlipHorizontal
stored false default false; |
|
Display image horizontally flipped. See also |
property FlipVertical: Boolean read GetFlipVertical write SetFlipVertical
stored false default false; |
|
Display image vertically flipped. See also |
property ProtectedSides: TBorder read GetProtectedSides stored false; |
|
Corners and edges of the image that are protected from scaling distortion when 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. See also
|
property DetectScaleFromUrl: Boolean
read FDetectScaleFromUrl write SetDetectScaleFromUrl default false; |
|
Set this to auto-detect that image is scaled compared to it's desired size. This detects URL endings like '[email protected]', and we will automatically adjust to it (the size determined by AutoSize will be actually 2x smaller than the PNG size). Preparing images at a 2x or 4x larger size than "desired" is a useful trick when using UI scaling, when you want the image to look good at various scales. |
property Rotation: Single read GetRotation write SetRotation stored false default 0; |
|
Rotation in radians. Default value 0. See also
|
property Clip: boolean read GetClip write SetClip stored false default false; |
|
Clip the image by an arbitrary 2D line defined in ClipLine. See also
|
property ColorPersistent: TCastleColorPersistent read FColorPersistent stored false; |
|
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 stored false; |
|
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 stored false; |
|
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
|
property RegionPersistent: TFloatRectanglePersistent read FRegionPersistent stored false; |
|
Region 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 Region directly. See also
|
Generated by PasDoc 0.16.0-snapshot.