You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "pretor_hq@wp.pl" <pr...@wp.pl> on 2010/02/18 16:05:38 UTC

HSLFSlideShow and Slide dimension problem

Hi, All!

I am using POI to display slides from PPT as Images in swing.
And I have a problem with size of images I get from draw method of Slide 
class.
I would like to set size of received image as 1024x768 but I do not know 
how to do this (by default it has smaller dimensions).

         *SlideShow ppt = new SlideShow(new HSLFSlideShow(new 
FileInputStream(file)));*
            //ppt.setPageSize(new Dimension (1024,768)); // extends size 
of slides but do not fit content

            Dimension pgsize = ppt.getPageSize();
            *Slide[] slide = ppt.getSlides();*       

            BufferedImage img = new BufferedImage(pgsize.width, 
pgsize.height, BufferedImage.TYPE_INT_RGB);
            Graphics2D graphics = img.createGraphics();
            graphics.setPaint(Color.white);
            graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, 
pgsize.height));
            *slide[0].draw(graphics);*
                       ImageIcon icn = new ImageIcon(img);

Is it possible to draw images in given dimensions?
If yes, how to do it ?

Best Regards

Re: HSLFSlideShow and Slide dimension problem

Posted by MSB <ma...@tiscali.co.uk>.
Ah, I understand now and simply missinterpreted your original post. Sorry to
say that I cannot be of any help because I know next to nothing about
Powerpoint and absolutly nothing about that part of the POI that supports
the file format.

Yours

Mark B


pretor_hq@wp.pl wrote:
> 
> Maybe I said that incorrectly.
> 
> The problem is NOT that I cant resize Image (its easy).
> The problem is that method
> 
> 	Slide.draw(Graphics g)
> 
> draws relatively small image (ie 800x600) and resizing it to 1024x768 is 
> useless because of poor quality or fesult (bitmap is not vector)
> 
> and I cant figure out how to set default Slide' default draw resolution 
> to 1024x768. so I can draw image in right quality (slides in PPT have 
> good quality).
> Regards
> 
> W dniu 22-02-2010 09:50, MSB pisze:
>> I know absolutly nothing about Powerpoint nor about the POI api that
>> supports
>> it but I would have thought that once you have the image then you should
>> use
>> the standrd Java API and I am confident that if you searched for code
>> that
>> told you how to resize an image using Java then you should find some
>> help.
>> Just did that myself and came across these links, one may help;
>>
>> http://www.velocityreviews.com/forums/t126229-resize-image-jpg-problem.html
>> http://www.webmaster-talk.com/coding-forum/63227-image-resizing-in-java.html
>> http://www.componenthouse.com/article-20
>> http://www.rgagnon.com/javadetails/java-0243.html
>> http://www.digitalsanctuary.com/tech-blog/java/how-to-resize-uploaded-images-using-java.html
>>
>> Yours
>>
>> Mark B
>>
>>
>> pretor_hq@wp.pl wrote:
>>    
>>> Maybe someone can tell me is it possible to scale Slide image (draw
>>> method) to given dimensions (without quaity loose), because I am
>>> searching without result.
>>> Anyone knows that ?
>>> Regards
>>>
>>> pretor_hq@wp.pl pisze:
>>>      
>>>> Hi, All!
>>>>
>>>> I am using POI to display slides from PPT as Images in swing.
>>>> And I have a problem with size of images I get from draw method of
>>>> Slide class.
>>>> I would like to set size of received image as 1024x768 but I do not
>>>> know how to do this (by default it has smaller dimensions).
>>>>
>>>>          *SlideShow ppt = new SlideShow(new HSLFSlideShow(new
>>>> FileInputStream(file)));*
>>>>             //ppt.setPageSize(new Dimension (1024,768)); // extends
>>>> size of slides but do not fit content
>>>>
>>>>             Dimension pgsize = ppt.getPageSize();
>>>>             *Slide[] slide = ppt.getSlides();*
>>>>             BufferedImage img = new BufferedImage(pgsize.width,
>>>> pgsize.height, BufferedImage.TYPE_INT_RGB);
>>>>             Graphics2D graphics = img.createGraphics();
>>>>             graphics.setPaint(Color.white);
>>>>             graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width,
>>>> pgsize.height));
>>>>             *slide[0].draw(graphics);*
>>>>                        ImageIcon icn = new ImageIcon(img);
>>>>
>>>> Is it possible to draw images in given dimensions?
>>>> If yes, how to do it ?
>>>>
>>>> Best Regards
>>>>
>>>>        
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>>> For additional commands, e-mail: user-help@poi.apache.org
>>>
>>>
>>>
>>>      
>>    
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/HSLFSlideShow-and-Slide-dimension-problem-tp27640306p27689622.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: HSLFSlideShow and Slide dimension problem

Posted by "pretor_hq@wp.pl" <pr...@wp.pl>.
Maybe I said that incorrectly.

The problem is NOT that I cant resize Image (its easy).
The problem is that method

	Slide.draw(Graphics g)

draws relatively small image (ie 800x600) and resizing it to 1024x768 is 
useless because of poor quality or fesult (bitmap is not vector)

and I cant figure out how to set default Slide' default draw resolution 
to 1024x768. so I can draw image in right quality (slides in PPT have 
good quality).
Regards

W dniu 22-02-2010 09:50, MSB pisze:
> I know absolutly nothing about Powerpoint nor about the POI api that supports
> it but I would have thought that once you have the image then you should use
> the standrd Java API and I am confident that if you searched for code that
> told you how to resize an image using Java then you should find some help.
> Just did that myself and came across these links, one may help;
>
> http://www.velocityreviews.com/forums/t126229-resize-image-jpg-problem.html
> http://www.webmaster-talk.com/coding-forum/63227-image-resizing-in-java.html
> http://www.componenthouse.com/article-20
> http://www.rgagnon.com/javadetails/java-0243.html
> http://www.digitalsanctuary.com/tech-blog/java/how-to-resize-uploaded-images-using-java.html
>
> Yours
>
> Mark B
>
>
> pretor_hq@wp.pl wrote:
>    
>> Maybe someone can tell me is it possible to scale Slide image (draw
>> method) to given dimensions (without quaity loose), because I am
>> searching without result.
>> Anyone knows that ?
>> Regards
>>
>> pretor_hq@wp.pl pisze:
>>      
>>> Hi, All!
>>>
>>> I am using POI to display slides from PPT as Images in swing.
>>> And I have a problem with size of images I get from draw method of
>>> Slide class.
>>> I would like to set size of received image as 1024x768 but I do not
>>> know how to do this (by default it has smaller dimensions).
>>>
>>>          *SlideShow ppt = new SlideShow(new HSLFSlideShow(new
>>> FileInputStream(file)));*
>>>             //ppt.setPageSize(new Dimension (1024,768)); // extends
>>> size of slides but do not fit content
>>>
>>>             Dimension pgsize = ppt.getPageSize();
>>>             *Slide[] slide = ppt.getSlides();*
>>>             BufferedImage img = new BufferedImage(pgsize.width,
>>> pgsize.height, BufferedImage.TYPE_INT_RGB);
>>>             Graphics2D graphics = img.createGraphics();
>>>             graphics.setPaint(Color.white);
>>>             graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width,
>>> pgsize.height));
>>>             *slide[0].draw(graphics);*
>>>                        ImageIcon icn = new ImageIcon(img);
>>>
>>> Is it possible to draw images in given dimensions?
>>> If yes, how to do it ?
>>>
>>> Best Regards
>>>
>>>        
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
>>
>>
>>      
>    

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


Re: HSLFSlideShow and Slide dimension problem

Posted by MSB <ma...@tiscali.co.uk>.
I know absolutly nothing about Powerpoint nor about the POI api that supports
it but I would have thought that once you have the image then you should use
the standrd Java API and I am confident that if you searched for code that
told you how to resize an image using Java then you should find some help.
Just did that myself and came across these links, one may help;

http://www.velocityreviews.com/forums/t126229-resize-image-jpg-problem.html
http://www.webmaster-talk.com/coding-forum/63227-image-resizing-in-java.html
http://www.componenthouse.com/article-20
http://www.rgagnon.com/javadetails/java-0243.html
http://www.digitalsanctuary.com/tech-blog/java/how-to-resize-uploaded-images-using-java.html

Yours

Mark B


pretor_hq@wp.pl wrote:
> 
> Maybe someone can tell me is it possible to scale Slide image (draw
> method) to given dimensions (without quaity loose), because I am
> searching without result.
> Anyone knows that ?
> Regards
> 
> pretor_hq@wp.pl pisze:
>> Hi, All!
>>
>> I am using POI to display slides from PPT as Images in swing.
>> And I have a problem with size of images I get from draw method of 
>> Slide class.
>> I would like to set size of received image as 1024x768 but I do not 
>> know how to do this (by default it has smaller dimensions).
>>
>>         *SlideShow ppt = new SlideShow(new HSLFSlideShow(new 
>> FileInputStream(file)));*
>>            //ppt.setPageSize(new Dimension (1024,768)); // extends 
>> size of slides but do not fit content
>>
>>            Dimension pgsize = ppt.getPageSize();
>>            *Slide[] slide = ppt.getSlides();*      
>>            BufferedImage img = new BufferedImage(pgsize.width, 
>> pgsize.height, BufferedImage.TYPE_INT_RGB);
>>            Graphics2D graphics = img.createGraphics();
>>            graphics.setPaint(Color.white);
>>            graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, 
>> pgsize.height));
>>            *slide[0].draw(graphics);*
>>                       ImageIcon icn = new ImageIcon(img);
>>
>> Is it possible to draw images in given dimensions?
>> If yes, how to do it ?
>>
>> Best Regards
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/HSLFSlideShow-and-Slide-dimension-problem-tp27640306p27684353.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: HSLFSlideShow and Slide dimension problem

Posted by "pretor_hq@wp.pl" <pr...@wp.pl>.
Maybe someone can tell me is it possible to scale Slide image (draw
method) to given dimensions (without quaity loose), because I am
searching without result.
Anyone knows that ?
Regards

pretor_hq@wp.pl pisze:
> Hi, All!
>
> I am using POI to display slides from PPT as Images in swing.
> And I have a problem with size of images I get from draw method of 
> Slide class.
> I would like to set size of received image as 1024x768 but I do not 
> know how to do this (by default it has smaller dimensions).
>
>         *SlideShow ppt = new SlideShow(new HSLFSlideShow(new 
> FileInputStream(file)));*
>            //ppt.setPageSize(new Dimension (1024,768)); // extends 
> size of slides but do not fit content
>
>            Dimension pgsize = ppt.getPageSize();
>            *Slide[] slide = ppt.getSlides();*      
>            BufferedImage img = new BufferedImage(pgsize.width, 
> pgsize.height, BufferedImage.TYPE_INT_RGB);
>            Graphics2D graphics = img.createGraphics();
>            graphics.setPaint(Color.white);
>            graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, 
> pgsize.height));
>            *slide[0].draw(graphics);*
>                       ImageIcon icn = new ImageIcon(img);
>
> Is it possible to draw images in given dimensions?
> If yes, how to do it ?
>
> Best Regards
>


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