You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Tobias Meissner <to...@gmail.com> on 2011/07/13 15:50:03 UTC

Issue concerning setanchor usage for poi hslf

Hi there,

I've got an issue here with the setAnchor method in poi hslf.
I'm trying to do the following:
I read a png picture file via the ByteArrayInputStream and want to add the
picture to a ppt slide which I've created.
Therefore I use the following lines:

ByteArrayInputStream bais = new ByteArrayInputStream(image);
int picID = slideShow.addPicture(img, Picture.PNG);
Picture p01 = new Picture(picID);
p01.setAnchor(setBoundings(posX, posY,pictureWidth,pictureHeight);
slide.addShape(p01);

This works. The only problem is: the Picture I want to add to the slide has
the size 431x450 Pixel.
I don't really get the unit which is used by POI in the setAnchor method,
it's not pixels (otherwise the picture is far too big).
But when I scale the picture I get aliasing effects (blurred) in the
PowerPoint slide which do not exist in the original picture file.
In the documentation I find a lot like MASTER_DPI, POINT_DPI and all that
stuff but I don't get it.

Question: How can I fix this?
Anyone an idea besides "use the right measurements"?

Thanks!

Re: Issue concerning setanchor usage for poi hslf

Posted by Tobias Meissner <to...@gmail.com>.
solved!

The problem is, that the call to setDefaultSize() produces an error in POI.
I just transferred the code of this method to my code, and now it works!!!

--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Issue-concerning-setanchor-usage-for-poi-hslf-tp4582742p5658564.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


Re: Issue concerning setanchor usage for poi hslf

Posted by Tobias Meissner <to...@gmail.com>.
Unfortunately this leads to an error:

	org.apache.poi.hslf.model.Picture.getPictureData(Picture.java:176)
	org.apache.poi.hslf.model.Picture.setDefaultSize(Picture.java:148)

Here is my code:
        byte[] img = (byte[]) pictureObject;
        ByteArrayInputStream bais = new ByteArrayInputStream(img);
        int picID = ppt.addPicture(img, Picture.PNG);
        Picture p01 = new Picture(picID);
        p01.setAnchor(setBoundings(20, 20,50,50));
        p01.setDefaultSize();
        slide.addShape(p01);

I just don't get the clue...

kind regards
Tobias

--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Issue-concerning-setanchor-usage-for-poi-hslf-tp4582742p5654575.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


Re: Issue concerning setanchor usage for poi hslf

Posted by Yegor Kozlov <ye...@dinom.ru>.
Call Picture.setDefaultSize()  after insert. It should resize your
image to the original dimensions.

Yegor

On Wed, Jul 13, 2011 at 5:50 PM, Tobias Meissner
<to...@gmail.com> wrote:
> Hi there,
>
> I've got an issue here with the setAnchor method in poi hslf.
> I'm trying to do the following:
> I read a png picture file via the ByteArrayInputStream and want to add the
> picture to a ppt slide which I've created.
> Therefore I use the following lines:
>
> ByteArrayInputStream bais = new ByteArrayInputStream(image);
> int picID = slideShow.addPicture(img, Picture.PNG);
> Picture p01 = new Picture(picID);
> p01.setAnchor(setBoundings(posX, posY,pictureWidth,pictureHeight);
> slide.addShape(p01);
>
> This works. The only problem is: the Picture I want to add to the slide has
> the size 431x450 Pixel.
> I don't really get the unit which is used by POI in the setAnchor method,
> it's not pixels (otherwise the picture is far too big).
> But when I scale the picture I get aliasing effects (blurred) in the
> PowerPoint slide which do not exist in the original picture file.
> In the documentation I find a lot like MASTER_DPI, POINT_DPI and all that
> stuff but I don't get it.
>
> Question: How can I fix this?
> Anyone an idea besides "use the right measurements"?
>
> Thanks!
>

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