Image¶
TImage is a data type that holds an image.
This is used manipulate and process an image such as resizing, rotating, bluring and much more. Or simply get/set a pixel color at a given (x,y) coord.
TImage.Create¶
function TImage.Create: TImage; static;
TImage.Create¶
function TImage.Create(Width, Height: Integer): TImage; static;
TImage.Create¶
function TImage.Create(FileName: String): TImage; static;
TImage.CreateFromString¶
function TImage.CreateFromString(Str: String): TImage; static;
TImage.CreateFromZip¶
function TImage.CreateFromZip(ZipFileName, ZipEntryName: String): TImage; static;
Load an image from a file inside a zip file.
TImage.CreateFromMatrix¶
function TImage.CreateFromMatrix(Mat: TIntegerMatrix): TImage; static;
TImage.CreateFromMatrix¶
function TImage.CreateFromMatrix(Mat: TSingleMatrix; ColorMapType: Integer = 0): TImage; static;
TImage.Free¶
procedure TImage.Free;
TImage.Data¶
function TImage.Data: PColorBGRA;
TImage.Width¶
function TImage.Width: Integer;
TImage.Height¶
function TImage.Height: Integer;
TImage.Center¶
function TImage.Center: TPoint;
TImage.GetDefaultPixel¶
function TImage.GetDefaultPixel: TColorBGRA;
TImage.SetDefaultPixel¶
procedure TImage.SetDefaultPixel(Value: TColorBGRA);
TImage.GetDrawColor¶
function TImage.GetDrawColor: TColor;
Returns the current drawing color.
Note
Red is the default value.
TImage.SetDrawColor¶
procedure TImage.SetDrawColor(Color: TColor);
Sets the current draw color.
Note
Red is the default value.
TImage.GetDrawAlpha¶
function TImage.GetDrawAlpha: Byte;
Returns the current draw alpha. 0 is completely transparent and 255 is completely opauge.
Note
255 is the default value.
TImage.SetDrawAlpha¶
procedure TImage.SetDrawAlpha(Value: Byte);
Sets the current draw color. This determines how transparent something is drawn.
Note
255 is the default value.
TImage.GetFontName¶
function TImage.GetFontName: String;
TImage.SetFontName¶
procedure TImage.SetFontName(Value: String);
TImage.GetFontSize¶
function TImage.GetFontSize: Single;
TImage.SetFontSize¶
procedure TImage.SetFontSize(Value: Single);
TImage.GetFontAntialiasing¶
function TImage.GetFontAntialiasing: Boolean;
TImage.SetFontAntialiasing¶
procedure TImage.SetFontAntialiasing(Value: Boolean);
TImage.GetFontBold¶
function TImage.GetFontBold: Boolean;
TImage.SetFontBold¶
procedure TImage.SetFontBold(Value: Boolean);
TImage.GetFontItalic¶
function TImage.GetFontItalic: Boolean;
TImage.SetFontItalic¶
procedure TImage.SetFontItalic(Value: Boolean);
TImage.GetAlpha¶
function TImage.GetAlpha(X, Y: Integer): Byte;
TImage.SetAlpha¶
procedure TImage.SetAlpha(X, Y: Integer; Alpha: Byte);
TImage.GetPixel¶
function TImage.GetPixel(X, Y: Integer): TColor;
TImage.SetPixel¶
procedure TImage.SetPixel(X, Y: Integer; Color: TColor);
TImage.GetPixels¶
function TImage.GetPixels(Points: TPointArray): TColorArray;
TImage.SetPixels¶
procedure TImage.SetPixels(Points: TPointArray; Color: TColor);
TImage.SetPixels¶
procedure TImage.SetPixels(Points: TPointArray; Colors: TColorArray);
TImage.InImage¶
function TImage.InImage(X, Y: Integer): Boolean;
TImage.SetSize¶
procedure TImage.SetSize(AWidth, AHeight: Integer);
TImage.SetExternalData¶
procedure TImage.SetExternalData(NewData: PColorBGRA; DataWidth, DataHeight: Integer);
Point the image data to external data (ie. not data allocated by the image itself).
TImage.ResetExternalData¶
procedure TImage.ResetExternalData;
Remove the effects of SetExternalData
.
TImage.Fill¶
procedure TImage.Fill(Color: TColor);
Fill the entire image with a color.
TImage.FillWithAlpha¶
procedure TImage.FillWithAlpha(Value: Byte);
Set the entire images alpha value.
TImage.Clear¶
procedure TImage.Clear;
Fills the entire image with the default pixel.
TImage.Clear¶
procedure TImage.Clear(Area: TBox);
Fills the given area with the default pixel.
TImage.ClearInverted¶
procedure TImage.ClearInverted(Area: TBox);
Fills everything but given area with the default pixel.
TImage.Copy¶
function TImage.Copy(Box: TBox): TImage;
TImage.Copy¶
function TImage.Copy: TImage;
TImage.Crop¶
procedure TImage.Crop(Box: TBox);
TImage.Pad¶
procedure TImage.Pad(Amount: Integer);
Pad an Amount
pixel border around the entire image.
TImage.Offset¶
procedure TImage.Offset(X,Y: Integer);
Offset the entire images content within itself.
TImage.SplitChannels¶
procedure TImage.SplitChannels(var B,G,R: TByteArray);
TImage.FromChannels¶
procedure TImage.FromChannels(const B,G,R: TByteArray; W, H: Integer);
TImage.GetColors¶
function TImage.GetColors: TColorArray;
TImage.GetColors¶
function TImage.GetColors(Box: TBox): TColorArray;
TImage.ReplaceColor¶
procedure TImage.ReplaceColor(OldColor, NewColor: TColor);
TImage.ReplaceColor¶
procedure TImage.ReplaceColor(OldColor, NewColor: TColor; Tolerance: Single);
TImage.Resize¶
function TImage.Resize(Algo: EImageResizeAlgo; NewWidth, NewHeight: Integer): TSimbaImage;
TImage.Resize¶
function TImage.Resize(Algo: EImageResizeAlgo; Scale: Single): TSimbaImage;
TImage.Rotate¶
function TImage.Rotate(Algo: EImageRotateAlgo; Radians: Single; Expand: Boolean): TSimbaImage;
TImage.Downsample¶
function TImage.Downsample(Scale: Integer): TImage;
TImage.Downsample¶
function TImage.Downsample(Scale: Integer; IgnorePoints: TPointArray): TImage;
Downsample but points in IgnorePoints
are not sampled from.
TImage.Mirror¶
function TImage.Mirror(Style: EImageMirrorStyle): TImage;
TImage.TextWidth¶
function TImage.TextWidth(Text: String): Integer;
TImage.TextHeight¶
function TImage.TextHeight(Text: String): Integer;
TImage.TextSize¶
function TImage.TextSize(Text: String): TPoint;
TImage.DrawText¶
procedure TImage.DrawText(Text: String; Position: TPoint; Color: TColor);
TImage.DrawText¶
procedure TImage.DrawText(Text: String; Box: TBox; Alignments: EImageTextAlign; Color: TColor);
TImage.DrawTextLines¶
procedure TImage.DrawTextLines(Text: TStringArray; Position: TPoint; Color: TColor);
TImage.DrawImage¶
procedure TImage.DrawImage(Image: TImage; Position: TPoint);
TImage.DrawATPA¶
procedure TImage.DrawATPA(ATPA: T2DPointArray);
Draws every TPA in the ATPA.
TImage.DrawTPA¶
procedure TImage.DrawTPA(Points: TPointArray);
Draws a TPointArray.
TImage.DrawLine¶
procedure TImage.DrawLine(Start, Stop: TPoint);
TImage.DrawLineGap¶
procedure TImage.DrawLineGap(Start, Stop: TPoint; GapSize: Integer);
TImage.DrawCrosshairs¶
procedure TImage.DrawCrosshairs(ACenter: TPoint; Size: Integer);
TImage.DrawCross¶
procedure TImage.DrawCross(ACenter: TPoint; Radius: Integer);
TImage.DrawBox¶
procedure TImage.DrawBox(B: TBox);
TImage.DrawBoxFilled¶
procedure TImage.DrawBoxFilled(B: TBox);
TImage.DrawBoxInverted¶
procedure TImage.DrawBoxInverted(B: TBox);
TImage.DrawPolygon¶
procedure TImage.DrawPolygon(Points: TPointArray);
TImage.DrawPolygonFilled¶
procedure TImage.DrawPolygonFilled(Points: TPointArray);
TImage.DrawPolygonInverted¶
procedure TImage.DrawPolygonInverted(Points: TPointArray);
TImage.DrawQuad¶
procedure TImage.DrawQuad(B: TBox);
TImage.DrawQuadFilled¶
procedure TImage.DrawQuadFilled(B: TBox);
TImage.DrawQuadInverted¶
procedure TImage.DrawQuadInverted(B: TBox);
TImage.DrawCircle¶
procedure TImage.DrawCircle(Center: TPoint; Radius: Integer);
TImage.DrawCircleFilled¶
procedure TImage.DrawCircleFilled(Center: TPoint; Radius: Integer);
TImage.DrawCircleInverted¶
procedure TImage.DrawCircleInverted(Center: TPoint; Radius: Integer);
TImage.DrawLineAA¶
procedure TImage.DrawLineAA(Start, Stop: TPoint; Color: TColor; Thickness: Single = 1.5);
TImage.DrawEllipseAA¶
procedure TImage.DrawEllipseAA(ACenter: TPoint; XRadius, YRadius: Integer; Color: TColor; Thickness: Single = 1.5);
TImage.DrawCircleAA¶
procedure TImage.DrawCircleAA(ACenter: TPoint; Radius: Integer; Color: TColor; Thickness: Single = 1.5);
TImage.DrawQuadArray¶
procedure TImage.DrawQuadArray(Quads: TQuadArray; Filled: Boolean);
TImage.DrawBoxArray¶
procedure TImage.DrawBoxArray(Boxes: TBoxArray; Filled: Boolean);
TImage.DrawPolygonArray¶
procedure TImage.DrawPolygonArray(Polygons: T2DPointArray; Filled: Boolean);
TImage.DrawCircleArray¶
procedure TImage.DrawCircleArray(Centers: TPointArray; Radius: Integer; Filled: Boolean);
TImage.DrawCrossArray¶
procedure TImage.DrawCrossArray(Points: TPointArray; Radius: Integer);
TImage.DrawHSLCircle¶
procedure TImage.DrawHSLCircle(ACenter: TPoint; Radius: Integer);
TImage.Sobel¶
function TImage.Sobel: TImage;
Applies a sobel overator on the image, and returns it.
TImage.Enhance¶
function TImage.Enhance(Enchantment: Byte; C: Single): TImage;
Enhances colors in the image by a given value.
Enhancement
: How much to substraact or add to the color.C
: Based on the “mid”-value (127) if color is below then it gets weakened else enchanced.
TImage.GreyScale¶
function TImage.GreyScale: TImage;
TImage.Brightness¶
function TImage.Brightness(Value: Integer): TImage;
TImage.Invert¶
function TImage.Invert: TImage;
TImage.Posterize¶
function TImage.Posterize(Value: Integer): TImage;
TImage.Convolute¶
function TImage.Convolute(Matrix: TDoubleMatrix): TImage;
Returns a full convolution with the given mask (Srouce?mask).
Hint
Mask should not be very large, as that would be really slow to proccess.
TImage.Threshold¶
function TImage.Threshold(Invert: Boolean = False; C: Integer = 0): TImage;
Otsu threshold algorithm.
Invert = Invert output C = Constant value to add to computed threshold
TImage.ThresholdAdaptive ———-’————-
function TImage.ThresholdAdaptive(Invert: Boolean = False; Radius: Integer = 25; C: Integer = 0): TImage;
Adapative thresholding using local average.
Invert = Invert output Radius = Window size, must be odd (default = 25) C = Constant value to add to computed threshold
TImage.ThresholdAdaptiveSauvola¶
function TImage.ThresholdAdaptiveSauvola(Invert: Boolean = False; Radius: Integer = 25; C: Single = 0.2): TImage;
Sauvola binarization algorithm.
Invert = Invert output Radius = Window size, must be odd (default = 25) C = Constant value (default = 0.2). Typical values are between 0.2 and 0.5.
TImage.Blend¶
function TImage.Blend(Points: TPointArray; Size: Integer): TImage;
TImage.Blend¶
function TImage.Blend(Points: TPointArray; Size: Integer; IgnorePoints: TPointArray): TImage;
Blend but points in IgnorePoints
are not sampled from.
TImage.Blur¶
function TImage.Blur(Algo: EImageBlurAlgo; Radius: Integer): TSimbaImage;
Algo can be either EImageBlurAlgo.BOX, EImageBlurAlgo.GAUSS.
Note
EImageBlurAlgo.GAUSS is not true gaussian blur it’s an approximation (in linear time).
TImage.ToGreyMatrix¶
function TImage.ToGreyMatrix: TByteMatrix;
TImage.ToMatrix¶
function TImage.ToMatrix: TIntegerMatrix;
TImage.ToMatrix¶
function TImage.ToMatrix(Box: TBox): TIntegerMatrix;
TImage.FromMatrix¶
procedure TImage.FromMatrix(Matrix: TIntegerMatrix);
Resizes the image to the matrix dimensions and draws the matrix.
TImage.FromMatrix¶
procedure TImage.FromMatrix(Matrix: TSingleMatrix; ColorMapType: Integer = 0);
Resizes the image to the matrix dimensions and draws the matrix.
ColorMapType can be: 0: cold blue to red 1: black -> blue -> red 2: white -> blue -> red 3: light (to white) 4: light (to black)
TImage.FromString¶
procedure TImage.FromString(Str: String);
TImage.FromData¶
procedure TImage.FromData(AWidth, AHeight: Integer; Memory: PColorBGRA; DataWidth: Integer);
TImage.Load¶
procedure TImage.Load(FileName: String);
TImage.Load¶
procedure TImage.Load(FileName: String; Area: TBox);
TImage.Save¶
function TImage.Save(FileName: String; OverwriteIfExists: Boolean = False): Boolean;
TImage.SaveToString¶
function TImage.SaveToString: String;
TImage.Equals¶
function TImage.Equals(Other: TImage): Boolean;
Are the two images exactly equal?
Note
Alpha is not taken into account.
TImage.Compare¶
function TImage.Compare(Other: TImage): Single;
TImage.PixelDifference¶
function TImage.PixelDifference(Other: TImage): Integer;
TImage.PixelDifference¶
function TImage.PixelDifference(Other: TImage; Tolerance: Integer): Integer;
TImage.PixelDifferenceTPA¶
function TImage.PixelDifferenceTPA(Other: TImage): TPointArray;
TImage.PixelDifferenceTPA¶
function TImage.PixelDifferenceTPA(Other: TImage; Tolerance: Integer): TPointArray;
TImage.ToLazBitmap¶
function TImage.ToLazBitmap: TLazBitmap;
TImage.FromLazBitmap¶
procedure TImage.FromLazBitmap(LazBitmap: TLazBitmap);
TImage.SaveUnfreedImagesInDir¶
procedure TImage.SaveUnfreedImagesInDir(Directory: String); static;
On script terminate if any images have not been freed save them to Directory
for debugging ease.
Example:
TImage.SaveUnfreedImagesInDir('some/directory/');
TImage.LoadFontsInDir¶
function TImage.LoadFontsInDir(Dir: String): Boolean; static;
Loads all “.ttf” fonts in the given directory.
TImage.Fonts¶
function TImage.Fonts: TStringArray; static;
Returns all the loaded font names.
TImage.Target¶
function TImage.Target: TTarget;
Returns a target which is targetted to the image. Use this to find colors and such on a image.
TImage.CreateFromTarget¶
function TImage.CreateFromTarget(Target: TSimbaTarget; Bounds: TBox = [-1,-1,-1,-1]): TImage; static;
Creates an image from the given target and bounds.
The
Bounds
parameter defaults to the entire target.
TImage.CreateFromTarget¶
function TImage.CreateFromTarget(Bounds: TBox = [-1,-1,-1,-1]): TImage; static;
Creates an image from the bounds of the current target.
Current target is the global Target variable
The
Bounds
parameter defaults to the entire target.
TImage.DrawTarget¶
procedure TImage.DrawTarget(Target: TSimbaTarget; P: TPoint; Bounds: TBox = [-1,-1,-1,-1]);
TImage.DrawTarget¶
procedure TImage.DrawTarget(P: TPoint; Bounds: TBox = [-1,-1,-1,-1]); overload;
TImage.Show¶
procedure TImage.Show(EnsureVisible: Boolean = True);
Show a image on the debug image.