Good day. I wanted to incorporate two functions to manipulate a bitmap image. I wanted to rotate and scale the same image. What I did was to use one of the given examples, the TRotLayer. My plan was to alter the TRotLayer. Here's what I did.
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;
On the first line, I changed TCustomLayer to TBitmapLayer so that I can use the Location property of TBitmapLayer to do resizing and scaling of the image. But when I started coding the scaling part, I couldn't seem to make it work using the Location property. Here's the code.
Selected := TRotLayer(ImgView.Layers.Items[i]);
frNewLoc := Selected.Location;
**altered the frNewLoc values (Left,Right,Top,Bottom) here**
Selected.Location := frNewLoc;
It didn't work. Where did I go wrong? Or is there a component that does have the scaling and rotating property all in one? Looking forward for your help. Thanks in advance.
Delphi Newbie here... :)