Class TRGBImage

Unit

Declaration

type TRGBImage = class(TCastleImage)

Description

Image with pixel represented as a TVector3Byte (red, green, blue).

Source: images/castleimages_class_rgb.inc (line 19).

Hierarchy

Overview

Methods

Protected procedure DrawFromCore(const Source: TCastleImage; const 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 class function PixelSize: Cardinal; override;
Public class function ColorComponentsCount: Cardinal; override;
Public function PixelPtr(const X, Y: Cardinal; const Z: Cardinal = 0): PVector3Byte;
Public function RowPtr(const Y: Cardinal; const Z: Cardinal = 0): PVector3ByteArray;
Public procedure InvertColors; override;
Public procedure Clear(const Pixel: TVector4Byte); override;
Public function IsClear(const Pixel: TVector4Byte): boolean; override;
Public procedure TransformRGB(const Matrix: TMatrix3); override;
Public procedure ModulateRGB(const ColorModulator: TColorModulatorByteFunc); override;
Public function ToRGBAlphaImage: TRGBAlphaImage; deprecated 'create TRGBAlphaImage and use TRGBAlphaImage.Assign';
Public function ToRGBFloat: TRGBFloatImage; deprecated 'create TRGBFloatImage and use TRGBFloatImage.Assign';
Public function ToGrayscale: TGrayscaleImage; deprecated 'create TGrayscaleImage and use TGrayscaleImage.Assign';
Public function ToFpImage: TInternalCastleFpImage; override;
Public procedure HorizontalLine(const x1, x2, y: Integer; const Color: TVector3Byte); overload;
Public procedure HorizontalLine(const x1, x2, y: Integer; const Color: TCastleColor); overload;
Public procedure VerticalLine(const x, y1, y2: Integer; const Color: TVector3Byte); overload;
Public procedure VerticalLine(const x, y1, y2: Integer; const Color: TCastleColor); overload;
Public constructor CreateCombined(const MapImage: TRGBImage; var ReplaceWhiteImage, ReplaceBlackImage: TRGBImage);
Public procedure LerpWith(const Value: Single; SecondImage: TCastleImage); override;
Public class procedure MixColors(const OutputColor: Pointer; const Weights: TVector4; const AColors: TVector4Pointer); 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: PVector3Byte read GetPixels;
Public property RGBPixels: PVector3Byte read GetPixels; deprecated 'use Pixels';
Public property PixelsArray: PVector3ByteArray read GetPixelsArray;

Description

Methods

Protected procedure DrawFromCore(const Source: TCastleImage; const X, Y, SourceX, SourceY, SourceWidth, SourceHeight: Integer; const Mode: TDrawMode); override;

This item has no description. Showing description inherited from TCastleImage.DrawFromCore.

Like DrawFrom, but can assume that all coordinates and sizes are valid. Override this to add copying using some more sophisticated method than just memory copying (so also for handling mode other than dmBlend).

Source: images/castleimages_class_rgb.inc (line 27).

Protected function GetColors(const X, Y, Z: Integer): TCastleColor; override;

This item has no description.

Source: images/castleimages_class_rgb.inc (line 30).

Protected procedure SetColors(const X, Y, Z: Integer; const C: TCastleColor); override;

This item has no description.

Source: images/castleimages_class_rgb.inc (line 31).

Public class function PixelSize: Cardinal; override;

This item has no description. Showing description inherited from TCastleImage.PixelSize.

Size of TPixel in bytes for this TCastleImage descendant.

Source: images/castleimages_class_rgb.inc (line 39).

Public class function ColorComponentsCount: Cardinal; override;

This item has no description. Showing description inherited from TCastleImage.ColorComponentsCount.

Number of color components in TPixel.

E.g. RGB is 3 components and RGB+Alpha is 4 components, RGB+Exponent is 3 components (because it describes only Red, Green and Blue values (Exponent value is just used to correctly interpret these, it's not a 4th component)).

Source: images/castleimages_class_rgb.inc (line 40).

Public function PixelPtr(const X, Y: Cardinal; const Z: Cardinal = 0): PVector3Byte;

This item has no description.

Source: images/castleimages_class_rgb.inc (line 42).

Public function RowPtr(const Y: Cardinal; const Z: Cardinal = 0): PVector3ByteArray;

This item has no description.

Source: images/castleimages_class_rgb.inc (line 43).

Public procedure InvertColors; override;

This item has no description. Showing description inherited from TCastleImage.InvertColors.

Inverts all colors (RGB or grayscale, but doesn't touch alpha channel). "Inverting" means changing color C in range [0..1] to 1-C, so black becomes white, white becomes black etc.

For descendants implementors: Override it if necessary, otherwise the default implementation in this class will raise EInternalError.

Source: images/castleimages_class_rgb.inc (line 45).

Public procedure Clear(const Pixel: TVector4Byte); override;

This item has no description. Showing description inherited from TCastleImage.Clear.

Set all image pixels to the same color.

Source: images/castleimages_class_rgb.inc (line 47).

Public function IsClear(const Pixel: TVector4Byte): boolean; override;

This item has no description. Showing description inherited from TCastleImage.IsClear.

Check do all image pixels have the same color.

Source: images/castleimages_class_rgb.inc (line 48).

Public procedure TransformRGB(const Matrix: TMatrix3); override;

This item has no description. Showing description inherited from TCastleImage.TransformRGB.

Multiply each RGB color by a matrix. This is a useful routine for many various conversions of image colors. Every pixel's RGB color is multiplied by given Matrix, i.e. PixelRGBColor := Matrix * PixelRGBColor.

If some value in some channel will be < 0, it will be set to 0. And if it will be > High(Byte), it will be set to High(Byte).

Examples: when Matrix = TMatrix3.Identity, this is NOOP. Matrix = ((2, 0, 0), (0, 1, 0), (0, 0, 1)) red channel is made lighter. Matrix = ((0, 0, 1), (0, 1, 0), (1, 0, 0)) swaps red and blue channel. Matrix = ((0.33, 0.33, 0.33), (0.33, 0.33, 0.33), (0.33, 0.33, 0.33)) is a simple conversion to grayscale (actually incorrect, even if often visually acceptable; actually instead of 0.33 one has to use GrayscaleFloat/ByteValues, this is already implemented in ImageTransformColorsVar function)

Note: it's often more optimal to hard-code necessary color transformations as TColorModulatorFunc and use ModulateRGB.

This function is only implemented for images that represent Pixel as RGB values, for now this means TRGBImage and TRGBAlphaImage. In case of TRGBAlphaImage (or any other class that represents colors as RGB + something more) alpha channel (i.e. "something more") is ignored (i.e. left without any modification).

In this class this simply raises EInternalError to say 'not implemented'. This also means that you must not call inherited in descendants when overriding this method.

Source: images/castleimages_class_rgb.inc (line 50).

Public procedure ModulateRGB(const ColorModulator: TColorModulatorByteFunc); override;

This item has no description. Showing description inherited from TCastleImage.ModulateRGB.

Process each pixel by given function. If ColorModulator = nil then this procedure does nothing. Else, every RGB color value of an image will be transformed using ColorModulator.

Like TransformRGB: This function is only implemented for images that represent Pixel as RGB values, for now this means TRGBImage and TRGBAlphaImage. In case of TRGBAlphaImage (or any other class that represents colors as RGB + something more) alpha channel (i.e. "something more") is ignored (i.e. left without any modification).

In this class this simply raises EInternalError to say 'not implemented'. This also means that you must not call inherited in descendants when overriding this method.

Source: images/castleimages_class_rgb.inc (line 51).

Public function ToRGBAlphaImage: TRGBAlphaImage; deprecated 'create TRGBAlphaImage and use TRGBAlphaImage.Assign';

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

Create a new TRGBAlphaImage instance with RGB contents copied from this image, and alpha fully opaque.

Source: images/castleimages_class_rgb.inc (line 55).

Public function ToRGBFloat: TRGBFloatImage; deprecated 'create TRGBFloatImage and use TRGBFloatImage.Assign';

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

Convert image to an TRGBFloatImage format.

Generally this conversion is safe, since Single can express more-or-less precisely (and definitely uniquely) all values that Byte can express. (Yeah, we have autotest for this statement.)

Source: images/castleimages_class_rgb.inc (line 62).

Public function ToGrayscale: TGrayscaleImage; deprecated 'create TGrayscaleImage and use TGrayscaleImage.Assign';

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

This item has no description.

Source: images/castleimages_class_rgb.inc (line 64).

Public function ToFpImage: TInternalCastleFpImage; override;

This item has no description. Showing description inherited from TEncodedImage.ToFpImage.

Convert image contents to FpImage instance. The resulting instance is owned by the caller.

Source: images/castleimages_class_rgb.inc (line 67).

Public procedure HorizontalLine(const x1, x2, y: Integer; const Color: TVector3Byte); overload;

Draw horizontal line. Must be y1 <= y2, else it is NOOP.

Source: images/castleimages_class_rgb.inc (line 71).

Public procedure HorizontalLine(const x1, x2, y: Integer; const Color: TCastleColor); overload;

This item has no description.

Source: images/castleimages_class_rgb.inc (line 73).

Public procedure VerticalLine(const x, y1, y2: Integer; const Color: TVector3Byte); overload;

Draw vertical line. Must be x1 <= x2, else it is NOOP.

Source: images/castleimages_class_rgb.inc (line 77).

Public procedure VerticalLine(const x, y1, y2: Integer; const Color: TCastleColor); overload;

This item has no description.

Source: images/castleimages_class_rgb.inc (line 79).

Public constructor CreateCombined(const MapImage: TRGBImage; var ReplaceWhiteImage, ReplaceBlackImage: TRGBImage);

Create image by merging two images according to a (third) mask image. This is a very special constructor. It creates image with the same size as MapImage. It also resizes ReplaceWhiteImage, ReplaceBlackImage to the size of MapImage.

Then it inits color of each pixel of our image with combined colors of two pixels on the same coordinates from ReplaceWhiteImage, ReplaceBlackImage, something like

Pixel[x, y] := ReplaceWhiteImage[x, y] * S +
               ReplaceBlackImage[x, y] * (S-1);

where S = average of red, gree, blue of color MapImage[x, y].

This means that final image will look like ReplaceWhiteImage in the areas where MapImage is white, and it will look like ReplaceBlackImage in the areas where MapImage is black.

Source: images/castleimages_class_rgb.inc (line 102).

Public procedure LerpWith(const Value: Single; SecondImage: TCastleImage); override;

This item has no description. Showing description inherited from TCastleImage.LerpWith.

Makes linear interpolation of colors from this image and the SecondImage. Intuitively, every pixel in new image is set to

(1 - Value) * Self[pixel] + Value * SecondImage[pixel]

Both images need to have the exact same size. If they are not, EImageLerpDifferentSizes is raised.

Not all TCastleImage combinations are allowed. Every subclass is required to override this to at least handle Lerp between itself. That is, TRGBImage.Lerp has to handle Lerp with other TRGBImage, TRGBAlphaImage.Lerp has to handle Lerp with other TRGBAlphaImage etc. Other combinations may be permitted, if useful and implemented. EImageLerpInvalidClasses is raised if given class combinations are not allowed.

In this class, this simply always raises EImageLerpInvalidClasses.

Source: images/castleimages_class_rgb.inc (line 105).

Public class procedure MixColors(const OutputColor: Pointer; const Weights: TVector4; const AColors: TVector4Pointer); override;

This item has no description. Showing description inherited from TCastleImage.MixColors.

Mix 4 colors, with 4 weights, into a resulting color. All 4 Colors and OutputColor must be pointers to a pixel of current image class, that is they must point to PixelSize bytes of memory.

Source: images/castleimages_class_rgb.inc (line 106).

Public procedure Assign(const Source: TCastleImage); override;

This item has no description. Showing description inherited from TCastleImage.Assign.

Copy size and contents from Source. This sets our size (Width, Height and Depth) to match Source image, and copies pixels from the Source image, converting them as closely as possible. For example, converting RGBA to RGB will strip alpha channel, but copy RGB values.

When implementing descendants: the base implementation of this method in TCastleImage handles only the case when Image class equals our own class. And raises EImageAssignmentError in other cases. Override this method if you want to actually handle some conversions when assignning.

Source: images/castleimages_class_rgb.inc (line 109).

Public procedure FillEllipse(const x, y: single; const aRadiusX, aRadiusY: single; const aColor: TCastleColor); override;

This item has no description. Showing description inherited from TCastleImage.FillEllipse.

Draw simple geometric shapes like circles, rectangles, lines, etc.

Source: images/castleimages_class_rgb.inc (line 112).

Public procedure Ellipse(const x, y: single; const aRadiusX, aRadiusY: single; const aWidth: single; const aColor: TCastleColor); override;

This item has no description.

Source: images/castleimages_class_rgb.inc (line 114).

Public procedure FillRectangle(const x1, y1, x2, y2: single; const aColor: TCastleColor); override;

This item has no description.

Source: images/castleimages_class_rgb.inc (line 116).

Public procedure Rectangle(const x1, y1, x2, y2: single; const aWidth: single; const aColor: TCastleColor); override;

This item has no description.

Source: images/castleimages_class_rgb.inc (line 118).

Public procedure Line(const x1, y1, x2, y2: single; const aWidth: single; const aColor: TCastleColor); override;

This item has no description.

Source: images/castleimages_class_rgb.inc (line 120).

Properties

Public property Pixels: PVector3Byte read GetPixels;

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

Source: images/castleimages_class_rgb.inc (line 34).

Public property RGBPixels: PVector3Byte read GetPixels; deprecated 'use Pixels';

Warning: this symbol is deprecated: use Pixels

This item has no description.

Source: images/castleimages_class_rgb.inc (line 35).

Public property PixelsArray: PVector3ByteArray read GetPixelsArray;

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

Source: images/castleimages_class_rgb.inc (line 37).


Generated by PasDoc 0.17.0.snapshot.