Class TGrayscaleMask

Unit

Declaration

type TGrayscaleMask = class(specialize TGenericUniversalBitmap<TByteMask,TByteMaskColorspace>)

Description

8-bit grayscale image.

Example on applying a grayscale mask:

A red triangle is masked using an ellipse shape. mask_poly

uses BGRABitmap, BGRABitmapTypes, BGRAGrayscaleMask;

procedure TForm1.FormPaint(Sender: TObject);
var tmp, layer: TBGRABitmap;
    mask: TGrayscaleMask;
    poly : ArrayOfTPointF;
begin
  layer := TBGRABitmap.Create(clientwidth, clientheight, BGRAPixelTransparent);
  setLength(Poly,3);
  poly[0] := PointF(10, 10);
  Poly[1] := PointF(layer.width-10, 10);
  Poly[2] := PointF(10, layer.height-10);
  layer.DrawPolygonAntialias(poly, cssBlack, 3, cssRed);

  mask := TGrayscaleMask.Create(clientwidth, clientheight, TByteMask.New(0));
  mask.FillEllipseAntialias(mask.Width/2-0.5, mask.Height/2-0.5,
                            mask.Width/2, mask.Height/2, TByteMask.New(255));
  layer.ApplyMask(mask);
  mask.Free;

  tmp := TBGRABitmap.create (clientwidth, clientheight, cssWhite);
  tmp.PutImage(0,0, layer, dmDrawWithTransparency);
  tmp.Draw (canvas,0,0);
  tmp.free;
end;

Hierarchy

Overview

Fields

Public ScanInterpolationFilter: TResampleFilter;

Methods

Public constructor Create(AWidth,AHeight: Integer; AValue: byte); overload;
Public constructor Create(ABitmap: TBGRACustomBitmap; AChannel: TChannel); overload;
Public constructor CreateDownSample(ABitmap: TGrayscaleMask; AWidth,AHeight: integer);
Public constructor CreateDownSample(ABitmap: TBGRACustomBitmap; AWidth,AHeight: integer);
Public constructor CreateDownSample(ABitmap: TGrayscaleMask; AWidth,AHeight: integer; ASourceRect: TRect);
Public constructor CreateDownSample(ABitmap: TBGRACustomBitmap; AWidth,AHeight: integer; ASourceRect: TRect);
Public function CreateBrushTexture(ABrushStyle: TBrushStyle; APatternColor, ABackgroundColor: TByteMask; AWidth: integer = 8; AHeight: integer = 8; APenWidth: single = 1): TGrayscaleMask; override;
Public function Duplicate(DuplicateProperties: Boolean = False): TGrayscaleMask; overload; override;
Public function FilterBlurMotion(distance: single; angle: single; oriented: boolean; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;
Public function FilterBlurMotion(const ABounds: TRect; distance: single; angle: single; oriented: boolean; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;
Public function FilterBlurRadial(radiusX, radiusY: single; blurType: TRadialBlurType; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;
Public function FilterBlurRadial(const ABounds: TRect; radius: single; blurType: TRadialBlurType; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;
Public function FilterBlurRadial(radius: single; blurType: TRadialBlurType; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;
Public function FilterBlurRadial(const ABounds: TRect; radiusX, radiusY: single; blurType: TRadialBlurType; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;
Public function FilterContour(ABorderValue: byte = 0): TGrayscaleMask;
Public function FilterCustomBlur(mask: TCustomUniversalBitmap; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;
Public function FilterCustomBlur(const ABounds: TRect; mask: TCustomUniversalBitmap; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;
Public function FilterCylinder: TGrayscaleMask;
Public function FilterSphere: TGrayscaleMask;
Public function GetImageBounds: TRect; overload; override;
Public function GetImageBoundsWithin(const ARect: TRect; Channels: TChannels; ANothingValue: Byte = 0): TRect; overload; override;
Public function GetImageBoundsWithin(const ARect: TRect; Channel: TChannel = cAlpha; ANothingValue: Byte = 0): TRect; overload; override;
Public function GetPart(const ARect: TRect; CopyProperties: Boolean=False): TGrayscaleMask; override;
Public function GetPixel(X,Y: integer): byte; overload;
Public function GetPixel(x, y: single; AResampleFilter: TResampleFilter = rfLinear; smoothBorder: boolean = true): TByteMask; overload;
Public function GetPixel256(x, y, fracX256,fracY256: int32or64; AResampleFilter: TResampleFilter = rfLinear; smoothBorder: boolean = true): TByteMask;
Public function GetUnique: TGrayscaleMask; override;
Public function NewBitmap(AWidth, AHeight: integer; const Color: TByteMask): TGrayscaleMask; overload; override;
Public function NewBitmap(AWidth, AHeight: integer; AColor: Pointer): TGrayscaleMask; overload; override;
Public function NewBitmap: TGrayscaleMask; overload; override;
Public function NewBitmap(AWidth, AHeight: integer): TGrayscaleMask; overload; override;
Public function NewReference: TGrayscaleMask; override;
Public function RotateCCW(ACopyProperties: Boolean=False): TGrayscaleMask; override;
Public function RotateCW(ACopyProperties: Boolean=False): TGrayscaleMask; override;
Public function RotateUD(ACopyProperties: Boolean=False): TGrayscaleMask; override;
Public function ScanAt(X, Y: Single): TBGRAPixel; override;
Public function ScanAtInteger(X, Y: integer): TBGRAPixel; override;
Public function ScanAtIntegerMask(X,Y: integer): TByteMask; override;
Public function ScanAtMask(X,Y: Single): TByteMask; override;
Protected function InternalGetPixel256(ix,iy: int32or64; iFactX,iFactY: int32or64; smoothBorder: boolean): TByteMask;
Protected function InternalGetPixelCycle256(ix,iy: int32or64; iFactX,iFactY: int32or64): TByteMask;
Protected function InternalNew: TCustomUniversalBitmap; override;
Public class procedure AlphaBrush(out ABrush: TUniversalBrush; AAlpha: Word); override;
Public procedure CopyFrom(ABitmap: TBGRACustomBitmap; AChannel: TChannel); overload;
Public procedure CopyFrom(ABitmap: TGrayscaleMask); overload;
Public procedure CopyPropertiesTo(ABitmap: TCustomUniversalBitmap); override;
Public procedure Draw(ABitmap: TBGRACustomBitmap; X,Y: Integer; AGammaCorrection: boolean = false);
Public procedure DrawAsAlpha(ABitmap: TBGRACustomBitmap; X,Y: Integer; texture: IBGRAScanner); overload;
Public procedure DrawAsAlpha(ABitmap: TBGRACustomBitmap; X,Y: Integer; const c: TBGRAPixel); overload;
Public class procedure EraseBrush(out ABrush: TUniversalBrush; AAlpha: Word); override;
Public procedure InplaceNormalize(ABounds: TRect); overload;
Public procedure InplaceNormalize; overload;
Public class procedure MaskBrush(out ABrush: TUniversalBrush; AScanner: IBGRAScanner; AOffsetX: integer = 0; AOffsetY: integer = 0); override;
Public procedure Negative;
Public procedure NegativeRect(ABounds: TRect);
Public class procedure ScannerBrush(out ABrush: TUniversalBrush; AScanner: IBGRAScanner; ADrawMode: TDrawMode = dmDrawWithTransparency; AOffsetX: integer = 0; AOffsetY: integer = 0); override;
Public procedure ScanNextMaskChunk(var ACount: integer; out AMask: PByteMask; out AStride: integer); override;
Public procedure SetPixel(X,Y: integer; AValue: byte);
Public class procedure SolidBrush(out ABrush: TUniversalBrush; const AColor: TByteMask; ADrawMode: TDrawMode = dmDrawWithTransparency); override;
Protected procedure AssignTransparentPixel(out ADest); override;
Protected procedure Init; override;

Properties

Public property Data: PByte read FDataByte;
Public property ScanLine[Y: Integer]: PByte read GetScanLine;

Description

Fields

Public ScanInterpolationFilter: TResampleFilter;

This item has no description.

Methods

Public constructor Create(AWidth,AHeight: Integer; AValue: byte); overload;

This item has no description.

Public constructor Create(ABitmap: TBGRACustomBitmap; AChannel: TChannel); overload;

This item has no description.

Public constructor CreateDownSample(ABitmap: TGrayscaleMask; AWidth,AHeight: integer);

This item has no description.

Public constructor CreateDownSample(ABitmap: TBGRACustomBitmap; AWidth,AHeight: integer);

This item has no description.

Public constructor CreateDownSample(ABitmap: TGrayscaleMask; AWidth,AHeight: integer; ASourceRect: TRect);

This item has no description.

Public constructor CreateDownSample(ABitmap: TBGRACustomBitmap; AWidth,AHeight: integer; ASourceRect: TRect);

This item has no description.

Public function CreateBrushTexture(ABrushStyle: TBrushStyle; APatternColor, ABackgroundColor: TByteMask; AWidth: integer = 8; AHeight: integer = 8; APenWidth: single = 1): TGrayscaleMask; override;

This item has no description.

Public function Duplicate(DuplicateProperties: Boolean = False): TGrayscaleMask; overload; override;

This item has no description.

Public function FilterBlurMotion(distance: single; angle: single; oriented: boolean; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;

This item has no description.

Public function FilterBlurMotion(const ABounds: TRect; distance: single; angle: single; oriented: boolean; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;

This item has no description.

Public function FilterBlurRadial(radiusX, radiusY: single; blurType: TRadialBlurType; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;

This item has no description.

Public function FilterBlurRadial(const ABounds: TRect; radius: single; blurType: TRadialBlurType; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;

This item has no description.

Public function FilterBlurRadial(radius: single; blurType: TRadialBlurType; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;

This item has no description. Showing description inherited from TCustomUniversalBitmap.FilterBlurRadial.

filters

Public function FilterBlurRadial(const ABounds: TRect; radiusX, radiusY: single; blurType: TRadialBlurType; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;

This item has no description.

Public function FilterContour(ABorderValue: byte = 0): TGrayscaleMask;

This item has no description.

Public function FilterCustomBlur(mask: TCustomUniversalBitmap; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;

This item has no description.

Public function FilterCustomBlur(const ABounds: TRect; mask: TCustomUniversalBitmap; ACopyProperties: Boolean=False): TGrayscaleMask; overload; override;

This item has no description.

Public function FilterCylinder: TGrayscaleMask;

This item has no description.

Public function FilterSphere: TGrayscaleMask;

This item has no description.

Public function GetImageBounds: TRect; overload; override;

This item has no description.

Public function GetImageBoundsWithin(const ARect: TRect; Channels: TChannels; ANothingValue: Byte = 0): TRect; overload; override;

This item has no description.

Public function GetImageBoundsWithin(const ARect: TRect; Channel: TChannel = cAlpha; ANothingValue: Byte = 0): TRect; overload; override;

This item has no description.

Public function GetPart(const ARect: TRect; CopyProperties: Boolean=False): TGrayscaleMask; override;

This item has no description. Showing description inherited from TCustomUniversalBitmap.GetPart.

Get a part of the image with repetition in both directions. It means that if the bounds are within the image, the result is just that part of the image, but if the bounds are bigger than the image, the image is tiled.

Public function GetPixel(X,Y: integer): byte; overload;

This item has no description.

Public function GetPixel(x, y: single; AResampleFilter: TResampleFilter = rfLinear; smoothBorder: boolean = true): TByteMask; overload;

This item has no description.

Public function GetPixel256(x, y, fracX256,fracY256: int32or64; AResampleFilter: TResampleFilter = rfLinear; smoothBorder: boolean = true): TByteMask;

This item has no description.

Public function GetUnique: TGrayscaleMask; override;

This item has no description. Showing description inherited from TCustomUniversalBitmap.GetUnique.

Returns an object with a reference count equal to 1. Duplicate this bitmap if necessary

Public function NewBitmap(AWidth, AHeight: integer; const Color: TByteMask): TGrayscaleMask; overload; override;

This item has no description.

Public function NewBitmap(AWidth, AHeight: integer; AColor: Pointer): TGrayscaleMask; overload; override;

This item has no description.

Public function NewBitmap: TGrayscaleMask; overload; override;

return type helpers

Public function NewBitmap(AWidth, AHeight: integer): TGrayscaleMask; overload; override;

This item has no description.

Public function NewReference: TGrayscaleMask; override;

This item has no description. Showing description inherited from TCustomUniversalBitmap.NewReference.

Adds a reference (this reference count is not the same as the reference count of an interface, it changes only by explicit calls)

Public function RotateCCW(ACopyProperties: Boolean=False): TGrayscaleMask; override;

This item has no description. Showing description inherited from TCustomUniversalBitmap.RotateCCW.

Return a new bitmap rotated in a counter clock wise direction.

Public function RotateCW(ACopyProperties: Boolean=False): TGrayscaleMask; override;

This item has no description. Showing description inherited from TCustomUniversalBitmap.RotateCW.

Return a new bitmap rotated in a clock wise direction.

Public function RotateUD(ACopyProperties: Boolean=False): TGrayscaleMask; override;

This item has no description. Showing description inherited from TCustomUniversalBitmap.RotateUD.

Return a new bitmap rotated 180° (upside down).

Public function ScanAt(X, Y: Single): TBGRAPixel; override;

This item has no description. Showing description inherited from IBGRAScanner.ScanAt.

Scan at any location using floating point coordinates

Public function ScanAtInteger(X, Y: integer): TBGRAPixel; override;

This item has no description. Showing description inherited from IBGRAScanner.ScanAtInteger.

Scan at any location using integer coordinates

Public function ScanAtIntegerMask(X,Y: integer): TByteMask; override;

This item has no description.

Public function ScanAtMask(X,Y: Single): TByteMask; override;

This item has no description.

Protected function InternalGetPixel256(ix,iy: int32or64; iFactX,iFactY: int32or64; smoothBorder: boolean): TByteMask;

This item has no description.

Protected function InternalGetPixelCycle256(ix,iy: int32or64; iFactX,iFactY: int32or64): TByteMask;

This item has no description.

Protected function InternalNew: TCustomUniversalBitmap; override;

This item has no description.

Public class procedure AlphaBrush(out ABrush: TUniversalBrush; AAlpha: Word); override;

This item has no description.

Public procedure CopyFrom(ABitmap: TBGRACustomBitmap; AChannel: TChannel); overload;

This item has no description.

Public procedure CopyFrom(ABitmap: TGrayscaleMask); overload;

This item has no description.

Public procedure CopyPropertiesTo(ABitmap: TCustomUniversalBitmap); override;

This item has no description.

Public procedure Draw(ABitmap: TBGRACustomBitmap; X,Y: Integer; AGammaCorrection: boolean = false);

This item has no description.

Public procedure DrawAsAlpha(ABitmap: TBGRACustomBitmap; X,Y: Integer; texture: IBGRAScanner); overload;

This item has no description.

Public procedure DrawAsAlpha(ABitmap: TBGRACustomBitmap; X,Y: Integer; const c: TBGRAPixel); overload;

This item has no description.

Public class procedure EraseBrush(out ABrush: TUniversalBrush; AAlpha: Word); override;

This item has no description.

Public procedure InplaceNormalize(ABounds: TRect); overload;

This item has no description.

Public procedure InplaceNormalize; overload;

This item has no description.

Public class procedure MaskBrush(out ABrush: TUniversalBrush; AScanner: IBGRAScanner; AOffsetX: integer = 0; AOffsetY: integer = 0); override;

This item has no description.

Public procedure Negative;

inplace filters

Public procedure NegativeRect(ABounds: TRect);

This item has no description.

Public class procedure ScannerBrush(out ABrush: TUniversalBrush; AScanner: IBGRAScanner; ADrawMode: TDrawMode = dmDrawWithTransparency; AOffsetX: integer = 0; AOffsetY: integer = 0); override;

This item has no description.

Public procedure ScanNextMaskChunk(var ACount: integer; out AMask: PByteMask; out AStride: integer); override;

This item has no description.

Public procedure SetPixel(X,Y: integer; AValue: byte);

This item has no description.

Public class procedure SolidBrush(out ABrush: TUniversalBrush; const AColor: TByteMask; ADrawMode: TDrawMode = dmDrawWithTransparency); override;

This item has no description.

Protected procedure AssignTransparentPixel(out ADest); override;

This item has no description.

Protected procedure Init; override;

This item has no description. Showing description inherited from TCustomUniversalBitmap.Init.

ReadWriteConfig: TBGRAReadWriteConfig;

Properties

Public property Data: PByte read FDataByte;

This item has no description.

Public property ScanLine[Y: Integer]: PByte read GetScanLine;

This item has no description.