TransparentMarkers

Parent Previous Next

Property TransparentMarkers : TTransparentMarkers - Published

TTransparentMarkers = class(TPersistent)
 public
   constructor Create(AnOwner : TImagePainter);
   procedure Assign(Source: TPersistent); override;
 published
  property Enabled : Boolean - read / write
  property CellWidth : integer - read / write
  property Color1 : TColor - read / write
  property Color2 : TColor - read / write
  property AdaptToPixelGrid : Boolean - read / write
  property OwnerDraw : Boolean - read /write
  property OnDraw : TDrawMarkerEvent - read /write
 end;

TDrawMarkerEvent =  procedure(Sender: TObject; Canvas : TCanvas; Rect : TRect; Marker1 : Boolean) of object;

TransparentMarkers makes it possible to mark the areas that are not occupied by objects with a chess board like pattern or a pattern you define yourself. The pattern will stay unaffected by zoom mode.  The pattern is a cosmetic effect only and is not saved with the image.

property Enabled
Turns the feature on and off. Default is off.

property CellWidth
The width of the squares. Default is 8 x 8 pixels. Minimum size is 4, max 50 pixels squared.

property Color1 and Color2
The color of the squares. Default is clSilver and clWhite.

property AdaptToPixelGrid
Combining a pixel grid and a transparent markers pattern may somewhat reduce the readability of the  image. Set AdaptToPixelGrid to ensure that the grid lines don't cross the marker squares. Default is false.

property OwnerDraw
Set OwnerDraw to enable customized drawing. If OwneDraw is true, you have to provide the drawing logic in the OnDraw event handler.

property OnDraw
Write an OnDraw event handler to draw a pattern of your own.
Sender is the transparent markers object that draws the pattern.
Canvas is the drawing surface
Rect is the square to draw the pattern element
Marker1 indicates the square alternation. A pattern may consist of to images drawn one after another. If Marker1 is true, the first image is to be drawn, if false the second image.

Note that the OnDraw event is not triggered unless OwnerDraw is true.

Note
TransparentMarkers can only be applied on a none bitmap background. 32 bit images do not support TransparentMarkers.
Because drawing of the markers requires some extra processing, you might expect a bit slower performance, notably with big images.