You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "mr.jonze" <mr...@gmail.com> on 2006/08/01 19:20:00 UTC

WMF Pictures

Hi,

I´m trying to retrieve the pictures from a PPT File, and I'm having trouble
getting WMF and EMF pictures. Is there anyway to get these? Where I´m wrong?

Here´s the code:

Slide s2 = s[i];
Shape[] sh = s2.getShapes();
        for (int j = 0; j < sh.length; j++)
        {
            if (sh[j] instanceof Picture)
            {
                pics++;
                Picture p = (Picture)sh[j];
                int type = p.getPictureData().getType();
                byte[] data = p.getPictureData().getData();
                if (type == Picture.JPEG)
                {
                    FileOutputStream out = new
FileOutputStream("pict"+j+".jpg");
                    out.write(data);
                    out.close();
                    System.out.println("Imagem criada: "+"pict"+j+".jpg");
                }
                else if(type == Picture.PNG)
                {
                    FileOutputStream out = new
FileOutputStream("pict"+j+".png");
                    out.write(data);
                    out.close();
                    System.out.println("Imagem criada: "+"pict"+j+".png");
                }
                else //In this case i will try to get the WMF and other
formats
                {
                    FileOutputStream out = new
FileOutputStream("pict"+j+".wmf");
                    out.write(data);
                    out.close();
                    System.out.println("Imagem criada: "+"pict"+j+".wmf");
                }
            }


Thanx,
Luis.

Re: WMF Pictures

Posted by Yegor Kozlov <ye...@dinom.ru>.
WMF pictures are not supported yet. Only JPEG and PNG can be
extracted.

 WMF it is stored compressed, i.e. PictureData.getData() returns you the
 compressed data, not the raw WMF bytes. I'm not sure if it can be
 unpacked using the standard java.util.zip.InflaterInputStream. I made
 a few unsuccessful attempts :).

I hope later I will implement all supported image formats: EMF, WMF, PICT,
JPEG, PNG and DIB. Just need time for it :).

Regards, Yegor

mj> Hi,

mj> I´m trying to retrieve the pictures from a PPT File, and I'm having trouble
mj> getting WMF and EMF pictures. Is there anyway to get these? Where I´m wrong?

mj> Here´s the code:

mj> Slide s2 = s[i];
mj> Shape[] sh = s2.getShapes();
mj>         for (int j = 0; j < sh.length; j++)
mj>         {
mj>             if (sh[j] instanceof Picture)
mj>             {
mj>                 pics++;
mj>                 Picture p = (Picture)sh[j];
mj>                 int type = p.getPictureData().getType();
mj>                 byte[] data = p.getPictureData().getData();
mj>                 if (type == Picture.JPEG)
mj>                 {
mj>                     FileOutputStream out = new
mj> FileOutputStream("pict"+j+".jpg");
mj>                     out.write(data);
mj>                     out.close();
mj>                     System.out.println("Imagem criada: "+"pict"+j+".jpg");
mj>                 }
mj>                 else if(type == Picture.PNG)
mj>                 {
mj>                     FileOutputStream out = new
mj> FileOutputStream("pict"+j+".png");
mj>                     out.write(data);
mj>                     out.close();
mj>                     System.out.println("Imagem criada: "+"pict"+j+".png");
mj>                 }
mj>                 else //In this case i will try to get the WMF and other
mj> formats
mj>                 {
mj>                     FileOutputStream out = new
mj> FileOutputStream("pict"+j+".wmf");
mj>                     out.write(data);
mj>                     out.close();
mj>                     System.out.println("Imagem criada: "+"pict"+j+".wmf");
mj>                 }
mj>             }


mj> Thanx,
mj> Luis.


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/