> By the way, I made a variant of resize(), called fitToRect(), which takes
> the image dimensions and scales the anchor rectangle so that the image
> will fit without becoming distorted. Worth submitting? My only question
> is how to specify the original anchor rectangle. In my app I use row,
> col, rows and char_widths to specify the original rectangle, but don't
> know that that's the 'natural' choice. But in any case, it makes more
> sense to fit an image to a rectangle on the spreadsheet than to just
> resize the anchor to the image's natural size.
>
Hi Yegor. Thanks for fixing my bug with the (float)'s.
About your 'resize scale factor' change. I took a slightly different
approach to coding this. It looks like your resize to scale will do most of
what my approach did, but doesn't really deal with how to figure out the
scale factor.
I coded a 'fit to rectangle' function that figures out the scale factor to
use by figuring out which dimension scales less to match the corresponding
rectangle dimension. Then, to be nice, it offsets the starting position of
the other dimension so that the resulting scaled image is also centered in
the given rectangle.
My app has to insert a logo image into a designated area in the header of a
spreadsheet, and has to work for different shaped logos (I imagine that's a
common problem). Again, I'm not sure what is the 'natural' way to specify
a spreadsheet rectangle, If rows and 'character positions' makes sense, I'd
be glad to submit my function.
Bottom line, though, is that I broke out the code from getPreferredSize that
maps the image size to the crazy XLS anchor parameters into a separate
'setAnchorToRectangle(int row, int col, float width, float height, float
xoffset, float yoffset)' method. This function maps the crazy anchor
parameters to real world parameters in pixels, and may come in handy in
other places. getPreferredSize() could just call it.
By the way, is this a reasonable forum to use for this kind of conversation?
--
View this message in context:
http://www.nabble.com/HSSFPicture%3AgetImageDimension-fails-under-eclipse-works-under-AIX-tp20448425p20531690.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]