Page 1 of 1

Can't modify image coordinates

Posted: Tue Mar 06, 2018 10:17 am
by coheris
Hi !
I'm using XLSReadWriteII 6.29 (trial version)

I have several images that I first insert at a default position (0,0,0,0) :

Code: Select all

picture := XLS[curSheet].Drawing.InsertImage(Filename, 0, 0, 0, 0);
Then I want to update later their placing using the following properties :

Code: Select all

picture.Col1 := _col;
picture.Row1 := _row;
picture.Col2 := Col2;
picture.Col2Offs := Col2Offset;
picture.Row2 := Row2;
picture.Row2Offs := Row2Offset;
But the images are still stuck at the top left.

Best regards !

Re: Can't modify image coordinates

Posted: Tue Mar 06, 2018 12:41 pm
by larsa
Hello

I cant reproduce this. Please note however that you must calculate the coordinates correct when changing position. It's much easier to insert the picture at the correct position at the first time.

Re: Can't modify image coordinates

Posted: Tue Mar 06, 2018 1:41 pm
by coheris
Hello,

The real issue is ours, then.
Thank you !

Best regards.

Re: Can't modify image coordinates

Posted: Mon Mar 12, 2018 5:31 pm
by coheris
Hi !

I've run my code with XLSReadWriteII 4.65, and I can say that the coordinates are corrects. Pictures are well-placed.
Modifications due to XLSRWII 6 compatibility aside, the algorithm to calculate coordinates is the same.
This is why I think there could be an issue in XLSRWII 6.

Maybe you are not able to reproduce if you insert 1 single image and then update its coordinates.
In my case, I can have 10 images, and process like this (the coordinates are updated once all images have been inserted) :

Code: Select all

insert image 0 at (0, 0, 0, 0)
insert image 1 at (0, 0, 0, 0)
...
insert image 9 at (0, 0, 0, 0)
update image X coordinates (0 <= X < 10)
Image X placing is not updated in XLSRWII 6.

This works with XLSRWII 4 but instead of inserting in file we just add it at no particular place :

Code: Select all

P := XLS.MSOPictures.Add();
Best regards.

Re: Can't modify image coordinates

Posted: Tue Mar 20, 2018 4:13 pm
by coheris
Hi !

Have you been able to reproduce this ?

Best regards.

Re: Can't modify image coordinates

Posted: Wed Mar 21, 2018 9:01 am
by larsa
Hello

No, I can't reproduce this. Here is the code I used:

Code: Select all

var
  DI1,DI2,DI3: TXLSDrawingImage;
begin
  DI1 := FXSS.XLS[0].Drawing.InsertImage('Image1.jpg',0,0,0,0);
  DI2 := FXSS.XLS[0].Drawing.InsertImage('Image2.jpg',0,0,0,0);
  DI3 := FXSS.XLS[0].Drawing.InsertImage('Image3.jpg',0,0,0,0);

  DI1.Col1 := 1;
  DI1.Col2 := 3;

  DI2.Col1 := 5;
  DI3.Col2 := 7;

  DI3.Col1 := 10;
  DI3.Col2 := 12;
end;

Re: Can't modify image coordinates

Posted: Wed Mar 21, 2018 10:01 am
by coheris
Hello,

Thank you :)

So it may comes from the way I retrieve the image, as the image insertion and the coordinates update are done in different functions.
Here is how I update the coordinates :

Code: Select all

var
XLS: TXLSReadWriteII5;
picture: TXLSDrawingImage;
Col2, Row2: integer;
Col2Offset, Row2Offset: double;
begin         
  XLS := TXLSReadWriteII5(_xls.xlsHandle);
  picture := XLS[0].Drawing.Images[_picIdx];

  GetPictCol2Row2(_xls, _col, _row, _cx, _cy, _zoom, @Col2, @Row2, @Col2Offset, @Row2Offset);  // OK : same result as with XLSRWII 4

  picture.Col1 := _col;                    // 12
  picture.Row1 := _row;                  // 0
  picture.Col2 := Col2;                     // 14
  picture.Col2Offs := Col2Offset;       // 0,736842105263158
  picture.Row2 := Row2;                  // 11
  picture.Row2Offs := Row2Offset;    // 0,0113636363636364

end;
I've also tried by using :

Code: Select all

picture := XLS[0].Drawing.Images.Items[_picIdx];
Best regards.

Re: Can't modify image coordinates

Posted: Fri Mar 23, 2018 4:30 pm
by coheris
Hi !

I've fixed my issue by stopping to do it in two times.

Best regards.