我希望能够通过单击按钮以编程方式调整一层(选定的一层)的大小。所以基本上我有一个 ImgView32,我给它添加了图层。选择了最后一个,然后我想按下一个按钮,然后单击该按钮,我希望放大所选图层...
我希望能够画出水平和垂直的线条,以允许用户绘制房屋的布局(2D)。但我希望用户能够在没有鼠标的情况下调整线条的大小......所以他应该能够在编辑框中输入宽度和高度,然后单击按钮将尺寸应用于相应的(选定的)行。
我怎样才能在graphics32中做到这一点?
我试过这样:
var
orig,Tmp: TBitmap32;
Transformation: TAffineTransformation;
begin
Tmp := TBitmap32.Create;
Orig := TBitmap32.Create;
Transformation := TAffineTransformation.Create;
if Selection is TBitmapLayer then
begin
orig := TBitmapLayer(Selection).Bitmap;
try
Transformation.BeginUpdate;
Transformation.SrcRect := FloatRect(0, 0, orig.Width+200, orig.Height+200);
Transformation.Translate(-0.5 * orig.Width, -0.5 * orig.Height);
tmp.SetSize(200,200);
Transformation.Translate(0.5 * Tmp.Width, 0.5 * Tmp.Height);
Transformation.EndUpdate;
orig.DrawMode := dmTransparent;
Transform(Tmp, orig, Transformation);
orig.Assign(Tmp);
orig.DrawMode := dmTransparent;
finally
Transformation.Free;
Tmp.Free;
end;
end;
end;
但是所选图层保持相同大小并且内容缩小......我不知道我做错了什么。请帮忙。
谢谢