Bug 55967

Summary: [PATCH] XSSFPicture method to resize with different scales in width and height
Product: POI Reporter: Rafael Moreti Santana <rafael.moreti>
Component: XSSFAssignee: POI Developers List <dev>
Severity: enhancement CC: rafael.moreti, solid.danil
Priority: P2    
Version: 3.9-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: Java Class to resize XSSFPicture with two different scales
JUnit test of modified resize and getPreferredSize

Description Rafael Moreti Santana 2014-01-07 17:33:40 UTC
Created attachment 31178 [details]
Java Class to resize XSSFPicture with two different scales

Because XSSFPicture is a final class, this method calls the XSSFPicture and resize it with different scales. The method getPreferredSize was modified to allow two scales. Both method can be found in the attachment of this bug.
Comment 1 Nick Burch 2014-01-08 14:32:29 UTC
Any chance you could write up a unit test or two for this new functionality?
Comment 2 Rafael Moreti Santana 2014-01-14 11:42:22 UTC
Sorry, the JUnit tests are from the company and they can't be shared. There is any test framework you use that can be shared so we can generate tests and post it here?
Comment 3 Rafael Moreti Santana 2014-01-15 15:32:45 UTC
Created attachment 31209 [details]
JUnit test of modified resize and getPreferredSize
Comment 4 Rafael Moreti Santana 2014-01-15 15:34:05 UTC
Just add an attachment that contains a JUnit test of the modified method resize.
Comment 5 Andreas Beeker 2014-11-12 00:33:58 UTC
Thank you for the patch.
I've moved the code to the common model for HSSF/XSSF.
The resizing is now based on the anchor, i.e. relative on how the picture was displayed before in the sheet, and not anymore solely on the embedded image dimensions.
If one wants to scale relatively to the embedded image, the resize() method without parameters needs to be called before the actual resize() with a parameter.
The resizing gave different results with HSSF/XSSF before, so I think it's ok to generalize it now and make it relatively to the anchor.

Now the initial position (top left corner) is kept.

I haven't changed the side effect of getPreferredSize(), although it actually sets something in the picture instead of just returning a dimension ...

Applied with r1638623
Comment 6 Andreas Beeker 2015-02-25 14:45:16 UTC
*** Bug 57634 has been marked as a duplicate of this bug. ***