Discussion:
[Lazarus] Brush Bitmap anomaly
Michael Van Canneyt via Lazarus
2018-07-15 18:19:35 UTC
Permalink
Hello,

When I draw a rectangle with a brush that contains a bitmap, it's impossible
to assign the bitmap directly from a glyph.

The following works: (BImage is a TBitBtn), the form is painted with the
image on the bitbutton.

procedure TMainForm.PaintBitmapBrush;

begin
FreeAndNil(FBrushBitmap);
FBrushBitmap:=TBitmap.Create;
FBrushBitmap.Width:=BImage.Glyph.Width;
FBrushBitmap.Height:=BImage.Glyph.Height;
FBrushBitmap.Canvas.Draw(0,0,BImage.Glyph);
Canvas.Brush.Bitmap:=FBrushBitmap;
Canvas.Rectangle(0,0,Width-1,Height-1);
end;

This does not work:

procedure TMainForm.PaintBitmapBrush;

begin
Canvas.Brush.Bitmap:=BImage.Glyph;
Canvas.Rectangle(0,0,Width-1,Height-1);
end;

Is this a bug or is this intentional ?

BImage.Glyph is of type TBitmap, so I would expect this to work as well...

Michael.
--

Loading...