1

再会。我想合并两个函数来操作位图图像。我想旋转和缩放相同的图像。我所做的是使用给定的示例之一,即 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;

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

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

4

0 回答 0