When Depth > 1, the image is actually a 3D (not just 2D!) image. We call the particular 2D layers then "slices". Although some TCastleImage
methods (and functions in other units, like CastleGLImages) still operate only on the 1st "slice", that is the 2D image on Depth = 0 — be careful. But many methods correctly take the depth into consideration.
Note that specifying rows from lower to upper follows an OpenGL standard, this makes using this unit with OpenGL straightforward.
Note that the only valid states of instances of this class are when (Width * Height * Depth > 0 and RawPixels <> nil) or (Width * Height * Depth = 0 and RawPixels = nil). Otherwise the fundamental assumption that RawPixels is a pointer to Width * Height * Depth pixels would be broken (as nil pointer cannot point to anything, and on the other side it's rather useless to have a pointer to 0 bytes (since you can never dereference it anyway) even if theoretically every PtrInt value can be treated as valid pointer to 0 bytes).
|
procedure LerpSimpleCheckConditions(SecondImage: TCastleImage); |
|
procedure DrawFromCore(const Source: TCastleImage; const X, Y, SourceX, SourceY, SourceWidth, SourceHeight: Integer; const Mode: TDrawMode); virtual; |
|
function MakeResizedToFpImage(ResizeWidth, ResizeHeight: Cardinal; const Interpolation: TResizeInterpolation): TInternalCastleFpImage; |
|
function GetColors(const X, Y, Z: Integer): TCastleColor; virtual; |
|
procedure SetColors(const X, Y, Z: Integer; const C: TCastleColor); virtual; |
|
procedure AssignProperties(const Source: TCastleImage); virtual; |
|
constructor Create; overload; virtual; |
|
constructor Create(const AWidth, AHeight: Cardinal; const ADepth: Cardinal = 1); overload; |
|
procedure Empty; |
|
procedure SetSize( const AWidth, AHeight: Cardinal; const ADepth: Cardinal = 1); overload; |
|
procedure SetSize(const Source: TCastleImage); overload; |
|
class function PixelSize: Cardinal; virtual; abstract; |
|
function Size: Cardinal; override; |
|
function ImageSize: Cardinal; deprecated; |
|
class function ColorComponentsCount: Cardinal; virtual; abstract; |
|
function PixelPtr(const X, Y: Cardinal; const Z: Cardinal = 0): Pointer; |
|
function RowPtr(const Y: Cardinal; const Z: Cardinal = 0): Pointer; |
|
procedure InvertColors; virtual; |
|
procedure SetColorRGB(const X, Y: Integer; const v: TVector3); deprecated 'use Colors[X, Y, 0] to get or set colors'; |
|
function MakeCopy: TCastleImage; |
|
function CreateCopy: TEncodedImage; override; |
|
procedure Resize(ResizeWidth, ResizeHeight: Cardinal; const Interpolation: TResizeInterpolation = riBilinear); |
|
procedure Resize3x3(const ResizeWidth, ResizeHeight: Cardinal; var Corners: TVector4Integer; const Interpolation: TResizeInterpolationInternal); deprecated 'This method is seldom useful, and it is confused with TCastleImage.DrawFrom3x3 and TDrawableImage.Draw3x3 too often. Please report if you have a use-case when this method is useful, otherwise it may get removed from the engine one day.'; |
|
function MakeResized(ResizeWidth, ResizeHeight: Cardinal; const Interpolation: TResizeInterpolation = riBilinear): TCastleImage; |
|
procedure FlipHorizontal; |
|
procedure FlipVertical; override; |
|
function MakeRotated(Angle: Integer): TCastleImage; |
|
procedure Rotate(const Angle: Integer); |
|
function MakeTiled(TileX, TileY: Cardinal): TCastleImage; |
|
function MakeExtracted(X0, Y0, ExtractWidth, ExtractHeight: Cardinal): TCastleImage; |
|
procedure Clear(const Pixel: TVector4Byte); overload; virtual; |
|
procedure Clear(const Pixel: TCastleColor); overload; |
|
function IsClear(const Pixel: TVector4Byte): boolean; overload; virtual; |
|
procedure TransformRGB(const Matrix: TMatrix3); virtual; |
|
procedure ModulateRGB(const ColorModulator: TColorModulatorByteFunc); virtual; |
|
function MakeModulatedRGB( const ColorModulator: TColorModulatorByteFunc): TCastleImage; |
|
procedure Grayscale; |
|
procedure ConvertToChannelRGB(Channel: Integer); |
|
procedure StripToChannelRGB(Channel: Integer); |
|
function IsEqual(Image: TCastleImage): boolean; |
|
function ArePartsEqual( const SelfX0, SelfY0, SelfWidth, SelfHeight: Cardinal; Image: TCastleImage; const ImageX0, ImageY0, ImageWidth, ImageHeight: Cardinal): boolean; overload; |
|
function ArePartsEqual( Image: TCastleImage; const ImageX0, ImageY0, ImageWidth, ImageHeight: Cardinal): boolean; overload; |
|
function ArePartsEqual( const SelfX0, SelfY0, SelfWidth, SelfHeight: Cardinal; Image: TCastleImage): boolean; overload; |
|
procedure DrawFrom(const Source: TCastleImage; const X, Y: Integer; const Mode: TDrawMode = dmBlend); overload; |
|
procedure DrawFrom(const Source: TCastleImage; X, Y, SourceX, SourceY, SourceWidth, SourceHeight: Integer; const Mode: TDrawMode = dmBlend); overload; |
|
procedure DrawFrom(const Source: TCastleImage; const X, Y: Integer; const SourceRect: TRectangle; const Mode: TDrawMode = dmBlend); overload; |
|
procedure DrawTo(const Destination: TCastleImage; const X, Y: Integer; const Mode: TDrawMode = dmBlend); |
|
procedure DrawFrom3x3(const DestinationRect: TRectangle; const Source: TCastleImage; const SourceCorners: TVector4Integer; const DrawMode: TDrawMode; const Interpolation: TResizeInterpolation = riBilinear); |
|
procedure LerpWith(const Value: Single; SecondImage: TCastleImage); virtual; |
|
class procedure MixColors(const OutputColor: Pointer; const Weights: TVector4; const AColors: TVector4Pointer); virtual; |
|
procedure Assign(const Source: TCastleImage); virtual; |
|
procedure SaveToPascalCode(const ImageName: string; var CodeInterface, CodeImplementation, CodeInitialization, CodeFinalization: string); |
|
procedure AlphaBleed(const ProgressTitle: string = ''); virtual; |
|
function MakeAlphaBleed(const ProgressTitle: string = ''): TCastleImage; virtual; |
|
procedure FillEllipse(const x, y: single; const aRadiusX, aRadiusY: single; const aColor: TCastleColor); virtual; |
|
procedure Ellipse(const x, y: single; const aRadiusX, aRadiusY: single; const aWidth: single; const aColor: TCastleColor); virtual; |
|
procedure FillRectangle(const x1, y1, x2, y2: single; const aColor: TCastleColor); virtual; |
|
procedure Rectangle(const x1, y1, x2, y2: single; const aWidth: single; const aColor: TCastleColor); virtual; |
|
procedure Line(const x1, y1, x2, y2: single; const aWidth: single; const aColor: TCastleColor); virtual; |
|
procedure FloodFill(const x, y: integer; const aColor: TCastleColor; const aThreshold: single = 0); |
|
procedure TransformRGB(const Matrix: TMatrix3); virtual; |
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.
|