Lazarus
Miscellaneous => Other => Topic started by: Giuseppe Ridinò on May 24, 2004, 08:13:31 pm
-
I really don't know if this is a bug, or it's me who doesn't understand it.
Take a TForm, with a Timage and a TButton.
This is the code of the TButton OnClick event:
procedure TForm1.Button1Click(Sender: TObject);
var
Vertex : array[0..3] of TPoint;
begin
with Image1.Picture.Bitmap do
begin
Width := ClientWidth;
Height := ClientHeight;
with Canvas do
begin
Brush.Style := bsSolid;
// red square
Vertex[0].X := 0; Vertex[0].Y := 0;
Vertex[1].X := 20; Vertex[1].Y := 0;
Vertex[2].X := 20; Vertex[2].Y := 20;
Vertex[3].X := 0; Vertex[3].Y := 20;
Brush.Color := clRed;
Polygon(Vertex);
// green square
Vertex[0].X := 20; Vertex[0].Y := 20;
Vertex[1].X := 40; Vertex[1].Y := 20;
Vertex[2].X := 40; Vertex[2].Y := 40;
Vertex[3].X := 20; Vertex[3].Y := 40;
Brush.Color := clGreen;
Polygon(Vertex);
end;
end;
end;
Obviously when user click on the button, two squares are drawn, a red one on the top-left and a green one on the bottom-right of the Timage object.
In fact, in case (A) Timage has Left:=0; Top:=0; Width:=40; Height:=40; I get something like that:
RRBBX
RRBBX
BBGGX
BBGGX
XXXXX
Legend:
R=RED COLOR
G=GREEN COLOR
B=BLACK COLOR (canvas background)
X=form background (background)
But in case (B) Timage has Left:=10; Top:=10; Width:=40; Height:=40; I get something like that:
XXXXX
XRRBX
XRRBX
XBBGX
XXXXX
which IS NOT WHAT I EXPECTED :shock:
I had expected something like that:
XXXXX
XRRBB
XRRBB
XBBGG
XBBGG
Am I wrong to expect that or what?
Thanks in advance to who will provide me with an explanation! :wink:
-
Hmm... I would have expected Image A in all cases. Since setting Top/Left of an image doesn't affect the internal image itself.
-
... setting Top/Left of an image doesn't affect the internal image itself.
I agree. :wink:
Maybe my "snapshots" are not clear. :roll:
The top-left character represents always the top-left corner of the Tform, not of Timage which top-left character is always R.
Maybe I shoud provide with the full project sources. :?:
-
I think it has nothing to do with th epainting. Now it looks like your image isn't moved/sized right.
-
Could BUG 360 be related to this problem?
-
Don't think so
- That problem was related on drawing to the control.cavas
- only the top row was affected
- your original image draws ok
-
I have found that this problem doesn't exist anymore with the latest Lazarus snapshot. :P