Page 1 of 1
How to rotate image during conversion
Posted: 18 Mar 2016, 15:53
by tf_2010
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
How to fill
Matrix: TFMatrix for such flipping tricks?
Re: How to rotate image during conversion
Posted: 26 May 2016, 17:37
by support
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
Re: How to rotate image during conversion
Posted: 29 May 2016, 20:33
by tf_2010
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);
Re: How to rotate image during conversion
Posted: 30 May 2016, 15:43
by support
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
Re: How to rotate image during conversion
Posted: 01 Jun 2016, 22:40
by tf_2010
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?