结合Graphics32组件的旋转和缩放功能

时间:2013-05-20 01:22:09

标签: delphi resize rotation scaling graphics32

美好的一天。我想结合两个函数来操作位图图像。我想旋转和缩放相同的图像。我所做的是使用给定的例子之一,TRotLayer。我的计划是改变TRotLayer。这就是我所做的。

TCustomAffineLayer = class(TBitmapLayer)
private
FAlphaHit: Boolean;
FTransformation: TAffineTransformation;
FBitmap: TBitmap32;
procedure BitmapChanged(Sender: TObject);
procedure SetBitmap(Value: TBitmap32);
protected
FBitmapCenter: TFloatPoint;
procedure AdjustTransformation; virtual;
function DoHitTest(X, Y: Integer): Boolean; override;
procedure Paint(Buffer: TBitmap32); override;
property Transformation: TAffineTransformation read FTransformation;
public
constructor Create(ALayerCollection: TLayerCollection); override;
destructor Destroy; override;
property AlphaHit: Boolean read FAlphaHit write FAlphaHit;
property Bitmap: TBitmap32 read FBitmap write SetBitmap;
end;

TRotLayer = class(TCustomAffineLayer)
private
FPosition: TFloatPoint;
FScaled: Boolean;
FAngle: Single;
procedure SetAngle(Value: Single);
procedure SetPosition(const Value: TFloatPoint);
procedure SetScaled(Value: Boolean);
procedure SetBitmapCenter(const Value: TFloatPoint);
protected
procedure AdjustTransformation; override;
public
property Angle: Single read FAngle write SetAngle;
property BitmapCenter: TFloatPoint read FBitmapCenter write SetBitmapCenter;
property Scaled: Boolean read FScaled write SetScaled;
property Position: TFloatPoint read FPosition write SetPosition;
end;

在第一行,我将TCustomLayer更改为TBitmapLayer,以便我可以使用TBitmapLayer的Location属性来调整图像大小和缩放。但是,当我开始编写缩放部分时,我似乎无法使用Location属性使其工作。这是代码。

Selected := TRotLayer(ImgView.Layers.Items[i]);
frNewLoc := Selected.Location;

**altered the frNewLoc values (Left,Right,Top,Bottom) here**

Selected.Location := frNewLoc;

它不起作用。我哪里做错了?或者是否有一个组件确实具有缩放和旋转属性?期待您的帮助。提前谢谢。

德尔福新手在这里...... :)

0 个答案:

没有答案