Class TRGBImage
Unit
Declaration
type TRGBImage = class(TCastleImage)
Description
Image with pixel represented as a TVector3Byte (red, green, blue).
Hierarchy
- TObject
- TEncodedImage
- TCastleImage
- TRGBImage
Overview
Methods
procedure DrawFromCore(const Source: TCastleImage; const X, Y, SourceX, SourceY, SourceWidth, SourceHeight: Integer; const Mode: TDrawMode); override; |
|
function GetColors(const X, Y, Z: Integer): TCastleColor; override; |
|
procedure SetColors(const X, Y, Z: Integer; const C: TCastleColor); override; |
|
class function PixelSize: Cardinal; override; |
|
class function ColorComponentsCount: Cardinal; override; |
|
function PixelPtr(const X, Y: Cardinal; const Z: Cardinal = 0): PVector3Byte; |
|
function RowPtr(const Y: Cardinal; const Z: Cardinal = 0): PVector3ByteArray; |
|
procedure InvertColors; override; |
|
procedure Clear(const Pixel: TVector4Byte); override; |
|
function IsClear(const Pixel: TVector4Byte): boolean; override; |
|
procedure TransformRGB(const Matrix: TMatrix3); override; |
|
procedure ModulateRGB(const ColorModulator: TColorModulatorByteFunc); override; |
|
function ToRGBAlphaImage: TRGBAlphaImage; deprecated 'create TRGBAlphaImage and use TRGBAlphaImage.Assign'; |
|
function ToRGBFloat: TRGBFloatImage; deprecated 'create TRGBFloatImage and use TRGBFloatImage.Assign'; |
|
function ToGrayscale: TGrayscaleImage; deprecated 'create TGrayscaleImage and use TGrayscaleImage.Assign'; |
|
function ToFpImage: TInternalCastleFpImage; override; |
|
procedure HorizontalLine(const x1, x2, y: Integer; const Color: TVector3Byte); overload; |
|
procedure HorizontalLine(const x1, x2, y: Integer; const Color: TCastleColor); overload; |
|
procedure VerticalLine(const x, y1, y2: Integer; const Color: TVector3Byte); overload; |
|
procedure VerticalLine(const x, y1, y2: Integer; const Color: TCastleColor); overload; |
|
constructor CreateCombined(const MapImage: TRGBImage; var ReplaceWhiteImage, ReplaceBlackImage: TRGBImage); |
|
procedure LerpWith(const Value: Single; SecondImage: TCastleImage); override; |
|
class procedure MixColors(const OutputColor: Pointer; const Weights: TVector4; const AColors: TVector4Pointer); override; |
|
procedure Assign(const Source: TCastleImage); override; |
|
procedure FillEllipse(const x, y: single; const aRadiusX, aRadiusY: single; const aColor: TCastleColor); override; |
|
procedure Ellipse(const x, y: single; const aRadiusX, aRadiusY: single; const aWidth: single; const aColor: TCastleColor); override; |
|
procedure FillRectangle(const x1, y1, x2, y2: single; const aColor: TCastleColor); override; |
|
procedure Rectangle(const x1, y1, x2, y2: single; const aWidth: single; const aColor: TCastleColor); override; |
|
procedure Line(const x1, y1, x2, y2: single; const aWidth: single; const aColor: TCastleColor); override; |
Properties
property Pixels: PVector3Byte read GetPixels; |
|
property RGBPixels: PVector3Byte read GetPixels; deprecated 'use Pixels'; |
|
property PixelsArray: PVector3ByteArray read GetPixelsArray; |
Description
Methods
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). |
function GetColors(const X, Y, Z: Integer): TCastleColor; override; |
|
This item has no description. |
procedure SetColors(const X, Y, Z: Integer; const C: TCastleColor); override; |
|
This item has no description. |
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. |
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)). |
function PixelPtr(const X, Y: Cardinal; const Z: Cardinal = 0): PVector3Byte; |
|
This item has no description. |
function RowPtr(const Y: Cardinal; const Z: Cardinal = 0): PVector3ByteArray; |
|
This item has no description. |
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. |
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. |
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. |
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. |
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. |
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. |
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.) |
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. |
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. |
procedure HorizontalLine(const x1, x2, y: Integer; const Color: TVector3Byte); overload; |
|
Draw horizontal line. Must be y1 <= y2, else it is NOOP. |
procedure HorizontalLine(const x1, x2, y: Integer; const Color: TCastleColor); overload; |
|
This item has no description. |
procedure VerticalLine(const x, y1, y2: Integer; const Color: TVector3Byte); overload; |
|
Draw vertical line. Must be x1 <= x2, else it is NOOP. |
procedure VerticalLine(const x, y1, y2: Integer; const Color: TCastleColor); overload; |
|
This item has no description. |
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. |
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.
|
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. |
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. |
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. |
procedure Ellipse(const x, y: single; const aRadiusX, aRadiusY: single; const aWidth: single; const aColor: TCastleColor); override; |
|
This item has no description. |
procedure FillRectangle(const x1, y1, x2, y2: single; const aColor: TCastleColor); override; |
|
This item has no description. |
procedure Rectangle(const x1, y1, x2, y2: single; const aWidth: single; const aColor: TCastleColor); override; |
|
This item has no description. |
procedure Line(const x1, y1, x2, y2: single; const aWidth: single; const aColor: TCastleColor); override; |
|
This item has no description. |
Properties
property Pixels: PVector3Byte read GetPixels; |
|
Pointer to pixels. Same as RawPixels, only typecasted to PVector3Byte. |
property RGBPixels: PVector3Byte read GetPixels; deprecated 'use Pixels'; |
|
Warning: this symbol is deprecated: use Pixels This item has no description. |
property PixelsArray: PVector3ByteArray read GetPixelsArray; |
|
Pointer to pixels. Same as RawPixels, only typecasted to PVector3ByteArray. |
Generated by PasDoc 0.16.0-snapshot.