Class TCastleImageControl

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TCastleImageControl = class(TUIRectangularControl)

Description

Image control inside OpenGL context. 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 TGLImage.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 function PositionInside(const Position: TVector2Single): boolean; 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;
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;
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 Proportional: boolean read FProportional write SetProportional default false;

Description

Methods

Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public procedure Render; override;
 
Public function PositionInside(const Position: TVector2Single): boolean; 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. This image is owned by this component. If you set this property to your custom TCastleImage instance you should leave memory management of this instance to this component. If necessary, you can always create a copy by TCastleImage.MakeCopy if you want to give here only a copy.

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 (respecing current Stretch and related properties).

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 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;

Warning: this symbol is deprecated.

Deprecated, use more flexible AlphaChannel instead.

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, Proportional 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 container (Rect corresponds to the container area).

  • Otherwise, if Stretch = True and Proportional = True, then 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.

  • Otherwise, if Stretch = True but no other condition (so FullSize = False and Proportional = False) then 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.

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 Proportional: boolean read FProportional write SetProportional default false;
 

Generated by PasDoc 0.14.0.