How to rotate image during conversion

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: admin, support, SDS

Post Reply
tf_2010
Posts: 6
Joined: 18 Mar 2016, 15:12

How to rotate image during conversion

Post by tf_2010 » 18 Mar 2016, 15:53

Hello!
Could anybody help me with a sample of code?
How to work with FCADParams of TsgCADIterate object?

I need to flip the output image horizontally or vertically using procedure Iterate :

Code: Select all

procedure Iterate(Proc, FinishProc: TsgCADEntityProc; var Params: TsgCADIterate).
Before calling Iterate necessary to set Params.Matrix field; it is initial value of coordinate transformation matrix. This matrix is automatically changed on enter to block reference and restored on exit from it. Params.Additional is user-defined; all other fields of Params are initialized by Iterate.
I also shoud call procedure

Code: Select all

DoScale2D(var P: TsgCADIterate);

How to fill Matrix: TFMatrix for such flipping tricks?

support
Posts: 2930
Joined: 30 Mar 2005, 11:36
Contact:

Re: How to rotate image during conversion

Post by support » 26 May 2016, 17:37

Hello,

To flip the coordinates horizontally or vertically, you should use the following matrices:

Code: Select all

const
  cnstHorizontalFlipMat: TFMatrix = (M:((1, 0, 0), (0, -1, 0), (0, 0, 1), (0, 0, 0)));
  cnstVerticalFlipMat: TFMatrix = (M:((-1, 0, 0), (0, 1, 0), (0, 0, 1), (0, 0, 0)));

Code: Select all

FCADParams.Matrix := cnstHorizontalFlipMat;
or

Code: Select all

FCADParams.Matrix := cnstVerticalFlipMat;
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

tf_2010
Posts: 6
Joined: 18 Mar 2016, 15:12

Re: How to rotate image during conversion

Post by tf_2010 » 29 May 2016, 20:33

Sorry but this solution doesn't work.Here is the code:

Code: Select all

             CADImg.LoadFromFile(odCADPicture.FileName);
             FCADParams.Matrix := cnstVerticalFlipMat;
             CADImg.GetExtents;
             CADImg.Converter.ImportMode := imImport;
             CADImg.Converter.AutoInsert := True;
             CADImg.Converter.Params := @FCADParams;
             CADImg.CurrentLayout.Iterate(CADImg.Converter, ReadCADEntities, FinishReadCADEntities);

support
Posts: 2930
Joined: 30 Mar 2005, 11:36
Contact:

Re: How to rotate image during conversion

Post by support » 30 May 2016, 15:43

Hello,

The entities coordinates should be flipped vertically in this case i.e the X coordinate values should change a sign from the + to a - sign and vice versa.

Could you test this solution in the SimpleImport demo project and post the contents of a text file saved with this project?


Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

tf_2010
Posts: 6
Joined: 18 Mar 2016, 15:12

Re: How to rotate image during conversion

Post by tf_2010 » 01 Jun 2016, 22:40

support wrote:Hello,
The entities coordinates should be flipped vertically in this case i.e the X coordinate values should change a sign from the + to a - sign and vice versa.
Could you test this solution in the SimpleImport demo project and post the contents of a text file saved with this project?
Mikhail
Thank you very much for answer. The const cnstHorizontalFlipMat helped me in my case 'cos I thought that the rotation from + Y to - Y should be made with cnstVerticalFlipMat const.
Could you also help me with the consts for scaling matrix?
I need to get the output entities with the exact resolution in pixels I'll choose. For example I got the SVG image made in InkScape with the resolution 800x600 px. And after Iterate I should have recalculated coordinates of the entities within the boundaries 1280x1024 px. How can I do such operation?

Post Reply