Recent

Author Topic: Transform/Rotate Bitmap help please  (Read 2475 times)

JasonLugg

  • Jr. Member
  • **
  • Posts: 67
Transform/Rotate Bitmap help please
« on: March 20, 2018, 04:10:17 pm »
Hi All

Thx in advance for any help!

I wish to rotate a TBGRABItmap (eventually using the mouse). I believe to do this I need to use an Affine Transformation? So far I have this but it does not rotate?

TestBox is a TBGRABitmap.

Code: Pascal  [Select][+][-]
  1.    Affine:= TBGRAAffineBitmapTransform.Create(TestBox, True);
  2.    Affine.RotateDeg(45.0);
  3.    TestBox.Fill(affine);
  4.    TestBox.Draw(Canvas2D.Canvas, 50,50, TRUE);
  5.    Canvas2D.Draw(Form1.Canvas,8,392, true);
  6.    Affine.free;
  7.  

What am I doing wrong?

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: Transform/Rotate Bitmap help please
« Reply #1 on: March 31, 2018, 08:51:32 pm »
TBGRAAffineBitmapTransform takes as an input the bitmap to be transformed. So here the input is TextBox.

The output should not be the same bitmap. It is the surface where the scanner will be drawn. So for example:
Code: Delphi  [Select][+][-]
  1.    Affine:= TBGRAAffineBitmapTransform.Create(TestBox, True);
  2.    Affine.RotateDeg(45.0);
  3.    Canvas2D.Fill(affine);
  4.    Canvas2D.Draw(Form1.Canvas,8,392, true);
  5.    Affine.free;

Note that PutImageAffine ou PutImageAngle functions of TBGRABitmap may already give you what you need. Also in general, it is better to avoid using the Canvas property of TBGRABitmap.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018