poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Y <ryampol...@yahoo.com>
Subject Re: images and anchors - controlling image size
Date Fri, 07 Nov 2008 15:18:54 GMT



Yegor Kozlov wrote:
> 
> Did you try HSSFPicture#resize()? This method sets the original picture
> size relative to top left corner.
> 

Yeah, I looked at that.  It uses the original size of the image, and
provides no way to scale it to fit a smaller area on the spreadsheet.  I
looked at the code, and internally, it's doing all the same tricks of
mapping the image size to anchor rows, columns and offsets.  I was just
hoping there'd be some easier mechanism implemented in the future before
trying to clone the resize() method and modify it for my purposes.

The whole 1/256 of a 'character position' thing is so wacky, and the
combination of points for row heights vs pseudo character positions for
column widths makes the code really hard to follow, but so be it.  I guess
that's why it's called Horrible Spread Sheet Format...  Gee, thanks
Microsoft.

By the way, I size my columns by character positions too.  The online data
grid that I'm converting into an xls is sized based on the width of a
fixed-pitch character in a given font.  I don't know where Excel comes up
with the value of 256, but I've found that my columns don't size nicely when
I just multiply by 256.  I've been using 312 for a spreadsheet based on an
8-point font setting and scaling that up or down when I choose a different
font size, and that's been working out to columns that hold about the same
amount of text as my online grid does.

I suppose I don't really care about the exact size of the image (since I'm
scaling images to fit in a rectangle).  However, I do want to get the aspect
ratio correct.  Resize() seems to have some constants defined to map between
cell widths, row point heights and image pixels.  Hard to imagine it works
in all cases, but I guess I'll give it a try.

-- 
View this message in context: http://www.nabble.com/images-and-anchors---controlling-image-size-tp20370056p20382578.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Mime
View raw message