From: "Earl F. Glynn" To: "Thérèse Hanquet" Subject: Re: Computer Lab Feedback Date: Monday, March 05, 2001 12:03 AM Hi, Thérèse: > I just looked at your lab report on Brush bitmaps and I > wondered how you had colored squares when setting brush style > to bsClear, because that's not what I get when I draw with this style. ... > Then I looked into the Print Demo it refers to, and I see that > after setting the brush style to bsClear you set the brush color. When I wrote Printer Demo #2 originally in D1 -- likely in 1995 or 1996 -- I wanted to compare the brush styles for the various colors on a variety of printers. I really didn't study why bsClear worked they way it did. I should have. You have an eagle eye and mind to catch this problem. > Finally I looked into graphics.pas and saw that setting the color for > the brush sets brush style to bsSolid if the style was previously bsClear. > Then what you endly get is not bsClear but bsSolid, which explains that > you get the same two first rows. I didn't understand exactly what you were saying until I studied the code you described. This short example shows the difference: // Why does Brush.Style = bsClear behave differently if // Brush.Color is set before or after? This behavior // appears to date back to D1. procedure TFormBSenigma.ButtonDrawRectsClick(Sender: TObject); VAR Bitmap: TBitmap; brush : WORD; y : WORD; begin Bitmap := TBitmap.Create; TRY Bitmap.Width := Image1.Width; Bitmap.Height := Image1.Height; FOR brush := 0 TO 7 DO // wrong bsClear behavior here? BEGIN Bitmap.Canvas.Brush.Style := TBrushStyle(brush); Bitmap.Canvas.Brush.Color := clRed; y := 5 + brush*20; Bitmap.Canvas.Rectangle (5, y, 5+20, y+20); END; FOR brush := 0 TO 7 DO // expected bsClear behavior BEGIN Bitmap.Canvas.Brush.Color := clRed; Bitmap.Canvas.Brush.Style := TBrushStyle(brush); y := 5 + brush*20; Bitmap.Canvas.Rectangle (55, y, 55+20, y+20); END; Image1.Picture.Graphic := Bitmap; FINALLY Bitmap.Free END end; > This behaviour is not what is explained in the online help, > which says that when you set the color after setting bsClear > it has no effect and the color is lost. Do you think it's a bug? My vote is "yes" this is a bug, but perhaps it's a feature I don't understand. ... Thanks for this interesting question. Best wishes, -- efg efg2@efg2.com Earl F. Glynn, Overland Park, KS USA efg's Computer Lab: http://www.efg2.com/Lab Mirror: http://homepages.borland.com/efg2lab/Default.htm