Class TCastleImageControl

Unit

Declaration

type TCastleImageControl = class(TUIControl)

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 TGLImageCore.Alpha). You can influence this by AlphaChannel property.

Hierarchy

Overview

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure Render; override;
Public procedure GLContextOpen; override;
Public procedure GLContextClose; override;
Public function Rect: TRectangle; override;
Public procedure ImageChanged;

Properties

Public property Image: TCastleImage read FImage write SetImage;
Public property OwnsImage: boolean read FOwnsImage write FOwnsImage default true;
Public property Color: TCastleColor read FColor write SetColor;
Public property Corners: TVector4Integer read FCorners write FCorners;
Public property CenterX: Single read FCenterX write SetCenterX default 0.5;
Public property CenterY: Single read FCenterY write SetCenterY default 0.5;
Public property Rotation: Single read FRotation write SetRotation default 0;
Public property Clip: boolean read FClip write SetClip;
Public property ClipLine: TVector3 read FClipLine write SetClipLine;
Published property URL: string read FURL write SetURL;
Published property FileName: string read FURL write SetURL; deprecated;
Published property AlphaChannel: TAutoAlphaChannel read FAlphaChannel write SetAlphaChannel default acAuto;
Published property Blending: boolean read GetBlending write SetBlending stored false; deprecated 'use AlphaChannel';
Published property SmoothScaling: boolean read FSmoothScaling write SetSmoothScaling default true;
Published property Stretch: boolean read FStretch write SetStretch default false;
Published property Width: Cardinal read FWidth write SetWidth default 0;
Published property Height: Cardinal read FHeight write SetHeight default 0;
Published property FullSize: boolean read FFullSize write SetFullSize default false;
Published property ProportionalScaling: TProportionalScaling read FProportionalScaling write SetProportionalScaling default psNone;
Published property Proportional: boolean read GetProportional write SetProportional stored false default false; deprecated 'use ProportionalScaling';

Description

Methods

Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public procedure Render; override;
 
Public procedure GLContextOpen; override;
 
Public procedure GLContextClose; override;
 
Public function Rect: TRectangle; override;
 
Public procedure ImageChanged;
 

Properties

Public property Image: TCastleImage read FImage write SetImage;

Image displayed, or Nil if none. You can set it by setting URL, or you can set this property directly if you loaded/created the image contents yourself.

Note that by default the TCastleImage instance assigned here is owned by this component (see OwnsImage). So if you set this property to your custom TCastleImage instance you should leave memory management of this instance to this component. You can either create a copy by TCastleImage.MakeCopy if you want to give here only a copy, or you can change OwnsImage to False.

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 actual rendered image. The control size will be updated immediately (taking into account current Stretch and related properties values).

Public property OwnsImage: boolean read FOwnsImage write FOwnsImage default true;

Whether the memory management of assigned Image is automatic. See Image documentation for details.

Public property Color: TCastleColor read FColor write SetColor;

Color tint of the image. This simply multiplies the image RGBA components, just like TGLImageCore.Color. By default this is opaque white, which means that image colors are unchanged.

Public property Corners: TVector4Integer read FCorners write FCorners;

Corners of the image that are not stretched even in case Stretch is used. See TGLImageCore.Draw3x3 for the details how drawing image with borders work.

Public property CenterX: Single read FCenterX write SetCenterX default 0.5;

X coordinate of the center of rotation. Value from 0 to 1. Default value 0.5.

Public property CenterY: Single read FCenterY write SetCenterY default 0.5;

Y coordinate of the center of rotation. Value from 0 to 1. Default value 0.5.

Public property Rotation: Single read FRotation write SetRotation default 0;

Rotation in radians. Default value 0.

Public property Clip: boolean read FClip write SetClip;

Clip the image by an arbitrary 2D line defined in ClipLine.

Public 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 A * x + B * y + C < 0.

The equation is calculated in the final scaled screen coordinates (not in the local, unscaled pixels). Adjust it to match the ScreenRect if necessary, to make it work with UI scaling.

Published property URL: string read FURL write SetURL;

URL of the image. Setting this also sets Image. Set this to '' to clear the image.

Published property FileName: string read FURL write SetURL; deprecated;

Warning: this symbol is deprecated.

Deprecated name for URL.

Published 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.

Published property Blending: boolean read GetBlending write SetBlending stored false; deprecated 'use AlphaChannel';

Warning: this symbol is deprecated: use AlphaChannel

Deprecated, use more flexible AlphaChannel instead.

Published property SmoothScaling: boolean read FSmoothScaling write SetSmoothScaling default true;

Is the image scaling mode smooth (bilinear filtering) or not (nearest-pixel filtering). See TGLImageCore.SmoothScaling.

Published property Stretch: boolean read FStretch write SetStretch default false;

Size of the image control.

If Stretch = False, then values you set for Width, Height, FullSize, ProportionalScaling properties do not matter (they are still remembered though, so you can set properties in any order). The displayed size (you can check it through Rect function) always corresponds to the underlying image size. The Left and Bottom properties work as usual, they allow you to move the control.

If Stretch = True, then the image will be stretched to fill the requested area.

  • If Stretch = True and FullSize = True then values of Width, Height, Left, Bottom do not matter: image always fills the whole parent (Rect corresponds to the parent area).

  • If Stretch = True and FullSize = False then the property ProportionalScaling determines how the the image will be adjusted to fit the requested Width and Height.

    psNone

    The image will be scaled to exactly fill the requested Width and Height (without paying attention to the aspect ratio of the image).

    This is the case when you fully force the displayed size and position, regardless of image size. Displayed image will always exactly fill the requested area.

    psFit

    The image will be proportionally scaled to fit within the requested Width and Height. If the aspect ratio of image will be different than aspect ratio of Width/Height, the scaled image will be centered inside the Width/Height.

    psEnclose

    The image will be proportionally scaled to enclode the requested Width and Height. If the aspect ratio of image will be different than aspect ratio of Width/Height, the scaled image will be larger then the requested area.

Note that you can always look at Rect value to know the current calculated size and position of the image control on screen.

Published property Width: Cardinal read FWidth write SetWidth default 0;
 
Published property Height: Cardinal read FHeight write SetHeight default 0;
 
Published property FullSize: boolean read FFullSize write SetFullSize default false;
 
Published property ProportionalScaling: TProportionalScaling read FProportionalScaling write SetProportionalScaling default psNone;
 
Published property Proportional: boolean read GetProportional write SetProportional stored false default false; deprecated 'use ProportionalScaling';

Warning: this symbol is deprecated: use ProportionalScaling

 

Generated by PasDoc 0.15.0.