1

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... :)

jhodzzz
  • 83
  • 1
  • 7
  • by the way, I could not use TImage32 for this coz it doesn't support images with transparent parts – jhodzzz May 20 '13 at 01:27
  • Please don't say "it didn't work". Please describe the failure in detail. What did you expect, and what actually occurred? – David Heffernan May 20 '13 at 07:04
  • I'm sorry sir David. I expected the image to resize when I call the second group of codes using the Location property but then it didn't do anything. Nothing changed. – jhodzzz May 20 '13 at 08:05
  • I ventured on another workaround about my problem and I think I'm much closer to the solution of my problem there. I posted another question [here](http://stackoverflow.com/questions/16645355/scaling-the-trotlayer). – jhodzzz May 20 '13 at 08:29
  • Your code formatting was lost during the posting. FYI: scaling and rotation are both subset of affine transforms – OnTheFly May 20 '13 at 11:26
  • I found that out yesterday, thanks for all the responses though. :) – jhodzzz May 21 '13 at 01:53

0 Answers0