unit ScreenDefineBrush; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TForm1 = class(TForm) ButtonBrush: TButton; Image1: TImage; procedure ButtonBrushClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.ButtonBrushClick(Sender: TObject); CONST PatternRows = 8; PatternColumns = 8; // Each hex digit is pixel in brush bitmap.. Pattern: ARRAY[0..PatternRows-1,0..PatternColumns DIV 2 - 1] OF BYTE = ( ($AA,$AA,$AA,$AA), ($AE,$00,$00,$B0), ($A0,$E0,$0B,$00), ($A0,$0E,$B0,$00), ($A0,$0B,$00,$00), ($A0,$B0,$E0,$00), ($AB,$C0,$0E,$00), ($A0,$00,$00,$E0)); VAR Bitmap: TBitmap; i : INTEGER; j : INTEGER; Row : pByteArray; begin Bitmap := TBitmap.Create; TRY Bitmap.Width := PatternColumns; Bitmap.Height := PatternRows; Bitmap.PixelFormat := pf4bit; // 4 bits/pixel // Fill the bitmap from the constant array // Each byte of scanline contains two pixels. // Each nibble of byte is a pixel. FOR j := 0 TO PatternRows-1 DO BEGIN Row := Bitmap.Scanline[j]; FOR i := 0 TO PatternColumns DIV 2 - 1 DO Row[i] := Pattern[j,i] END; WITH Image1.Canvas DO BEGIN Brush.Bitmap := Bitmap; FillRect( Rect(0,0, Width, Height) ); END FINALLY Bitmap.Free END end; end.