Forum > Other
[BUG?] Timage
Giuseppe RidinĂ²:
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:
--- Code: ---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;
--- End code ---
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:
Marc:
Hmm... I would have expected Image A in all cases. Since setting Top/Left of an image doesn't affect the internal image itself.
Giuseppe RidinĂ²:
--- Quote from: "Marc" ---... setting Top/Left of an image doesn't affect the internal image itself.
--- End quote ---
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. :?:
Marc:
I think it has nothing to do with th epainting. Now it looks like your image isn't moved/sized right.
Giuseppe RidinĂ²:
Could BUG 360 be related to this problem?
Navigation
[0] Message Index
[#] Next page