Class TGrayscaleImage

Unit

Declaration

type TGrayscaleImage = class(TCastleImage)

Description

Grayscale image. Color is a simple Byte value.

Hierarchy

Overview

Methods

Protected procedure DrawFromCore(Source: TCastleImage; X, Y, SourceX, SourceY, SourceWidth, SourceHeight: Integer; const Mode: TDrawMode); override;
Protected function GetColors(const X, Y, Z: Integer): TCastleColor; override;
Protected procedure SetColors(const X, Y, Z: Integer; const C: TCastleColor); override;
Public constructor Create; overload; override;
Public class function PixelSize: Cardinal; override;
Public class function ColorComponentsCount: Cardinal; override;
Public function PixelPtr(const X, Y: Cardinal; const Z: Cardinal = 0): PByte;
Public function RowPtr(const Y: Cardinal; const Z: Cardinal = 0): PByteArray;
Public procedure InvertColors; override;
Public procedure Clear(const Pixel: TVector4Byte); override;
Public function IsClear(const Pixel: TVector4Byte): boolean; override;
Public procedure Clear(const Pixel: Byte); reintroduce; overload;
Public function IsClear(const Pixel: Byte): boolean; reintroduce; overload;
Public procedure HalfColors;
Public function ToGrayscaleAlphaImage: TGrayscaleAlphaImage; deprecated 'create TGrayscaleAlphaImage and use TGrayscaleAlphaImage.Assign';
Public function ToFpImage: TInternalCastleFpImage; override;
Public procedure LerpWith(const Value: Single; SecondImage: TCastleImage); override;
Public class procedure MixColors(const OutputColor: Pointer; const Weights: TVector4; const AColors: TVector4Pointer); override;
Public function AlphaChannel( const AlphaTolerance: Byte): TAlphaChannel; override;
Public procedure Assign(const Source: TCastleImage); override;
Public procedure FillEllipse(const x, y: single; const aRadiusX, aRadiusY: single; const aColor: TCastleColor); override;
Public procedure Ellipse(const x, y: single; const aRadiusX, aRadiusY: single; const aWidth: single; const aColor: TCastleColor); override;
Public procedure FillRectangle(const x1, y1, x2, y2: single; const aColor: TCastleColor); override;
Public procedure Rectangle(const x1, y1, x2, y2: single; const aWidth: single; const aColor: TCastleColor); override;
Public procedure Line(const x1, y1, x2, y2: single; const aWidth: single; const aColor: TCastleColor); override;

Properties

Public property Pixels: PByte read GetPixels;
Public property GrayscalePixels: PByte read GetPixels; deprecated 'use Pixels';
Public property PixelsArray: PByteArray read GetPixelsArray;
Public property TreatAsAlpha: boolean read FTreatAsAlpha write FTreatAsAlpha default false;
Public property ColorWhenTreatedAsAlpha: TVector3Byte read FColorWhenTreatedAsAlpha write SetColorWhenTreatedAsAlpha;
Public property GrayscaleColorWhenTreatedAsAlpha: Byte read FGrayscaleColorWhenTreatedAsAlpha;

Description

Methods

Protected procedure DrawFromCore(Source: TCastleImage; X, Y, SourceX, SourceY, SourceWidth, SourceHeight: Integer; const Mode: TDrawMode); override;
 
Protected function GetColors(const X, Y, Z: Integer): TCastleColor; override;
 
Protected procedure SetColors(const X, Y, Z: Integer; const C: TCastleColor); override;
 
Public constructor Create; overload; override;
 
Public class function PixelSize: Cardinal; override;
 
Public class function ColorComponentsCount: Cardinal; override;
 
Public function PixelPtr(const X, Y: Cardinal; const Z: Cardinal = 0): PByte;
 
Public function RowPtr(const Y: Cardinal; const Z: Cardinal = 0): PByteArray;
 
Public procedure InvertColors; override;
 
Public procedure Clear(const Pixel: TVector4Byte); override;
 
Public function IsClear(const Pixel: TVector4Byte): boolean; override;
 
Public procedure Clear(const Pixel: Byte); reintroduce; overload;
 
Public function IsClear(const Pixel: Byte): boolean; reintroduce; overload;
 
Public procedure HalfColors;

Every pixels value is halved (divided by 2). This is done by simple bitshift, so you can be sure that all components are < 2ˆ7 after this.

Public function ToGrayscaleAlphaImage: TGrayscaleAlphaImage; deprecated 'create TGrayscaleAlphaImage and use TGrayscaleAlphaImage.Assign';

Warning: this symbol is deprecated: create TGrayscaleAlphaImage and use TGrayscaleAlphaImage.Assign

Add alpha channel.

If TreatAsAlpha = False: add constant opaque alpha.

If TreatAsAlpha = True: output alpha will be derived from source grayscale, output intensity will be derived from ColorWhenTreatedAsAlpha.

Public function ToFpImage: TInternalCastleFpImage; override;
 
Public procedure LerpWith(const Value: Single; SecondImage: TCastleImage); override;
 
Public class procedure MixColors(const OutputColor: Pointer; const Weights: TVector4; const AColors: TVector4Pointer); override;
 
Public function AlphaChannel( const AlphaTolerance: Byte): TAlphaChannel; override;
 
Public procedure Assign(const Source: TCastleImage); override;
 
Public procedure FillEllipse(const x, y: single; const aRadiusX, aRadiusY: single; const aColor: TCastleColor); override;
 
Public procedure Ellipse(const x, y: single; const aRadiusX, aRadiusY: single; const aWidth: single; const aColor: TCastleColor); override;
 
Public procedure FillRectangle(const x1, y1, x2, y2: single; const aColor: TCastleColor); override;
 
Public procedure Rectangle(const x1, y1, x2, y2: single; const aWidth: single; const aColor: TCastleColor); override;
 
Public procedure Line(const x1, y1, x2, y2: single; const aWidth: single; const aColor: TCastleColor); override;
 

Properties

Public property Pixels: PByte read GetPixels;

Pointer to pixels. Same as RawPixels, only typecasted to PByte.

Public property GrayscalePixels: PByte read GetPixels; deprecated 'use Pixels';

Warning: this symbol is deprecated: use Pixels

 
Public property PixelsArray: PByteArray read GetPixelsArray;

Pointer to pixels. Same as RawPixels, only typecasted to PByteArray.

Public property TreatAsAlpha: boolean read FTreatAsAlpha write FTreatAsAlpha default false;

Should we treat grayscale image as pure alpha channel (without any color information) when using this as a texture.

This property is meaningful only for a small subset of operations.

  1. When creating OpenGL texture from this image. If True, then the grayscale pixel data will be loaded as alpha channel contents (GL_ALPHA texture for OpenGL, it modifies only the fragments alpha value, it doesn't have any "color" in the normal sense). It is also the only way for TGrayscaleImage to return AlphaChannel <> acNone.

  2. When using DrawFrom / DrawTo methods or being assigned to something using Assign. If True, this image is drawn like an RGBA image, with constant RGB color ColorWhenTreatedAsAlpha, and alpha channel taken from contents of this image.

Public property ColorWhenTreatedAsAlpha: TVector3Byte read FColorWhenTreatedAsAlpha write SetColorWhenTreatedAsAlpha;

Used for drawing/assigning when TreatAsAlpha is True, and we need the base (not alpha) color for some equation. By default white (255, 255, 255).

Public property GrayscaleColorWhenTreatedAsAlpha: Byte read FGrayscaleColorWhenTreatedAsAlpha;

Automatically derived from ColorWhenTreatedAsAlpha by averaging RGB components to calculate grayscale intensity. By default 255.


Generated by PasDoc 0.16.0.