org.apache.poi.hslf.usermodel
Class Picture

java.lang.Object
  extended by org.apache.poi.hslf.usermodel.Picture

public class Picture
extends java.lang.Object

Represents a picture in a PowerPoint document.

The information about an image in PowerPoint document is stored in two places:

  • EscherBSE container in the Document keeps information about image type, image index to refer by slides etc.
  • "Pictures" OLE stream holds the actual data of the image.

    Data in the "Pictures" OLE stream is organized as follows:
    For each image there is an entry: 25 byte header + image data. Image data is the exact content of the JPEG file, i.e. PowerPoint puts the whole jpeg file there without any modifications.
    Header format:

  • 2 byte: image type. For JPEGs it is 0x46A0, for PNG it is 0x6E00.
  • 2 byte: unknown.
  • 4 byte : image size + 17. Looks like shift from the end of header but why to add it to the image size?
  • next 16 bytes. Unique identifier of this image which is used by EscherBSE record.

    Author:
    Yegor Kozlov

    Field Summary
    static int DIB
              Windows DIB (BMP)
    protected  byte[] header
              Header which holds information about this picture
    static int HEADER_SIZE
              The size of the header
    static int JPEG
              JPEG
    static int PICT
              Macintosh PICT
    protected  byte[] pictdata
              Binary data of the picture
    static int PNG
              PNG
    static int WMF
              Windows Metafile
     
    Constructor Summary
    Picture(byte[] pictstream, int offset)
              Read a picture from "Pictures" OLE stream
     
    Method Summary
     byte[] getData()
               
     int getSize()
              Return image size in bytes
     int getType()
              Returns the type of this picture.
     byte[] getUID()
              Returns the unique identifier (UID) of this picture.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    WMF

    public static final int WMF
    Windows Metafile

    See Also:
    Constant Field Values

    PICT

    public static final int PICT
    Macintosh PICT

    See Also:
    Constant Field Values

    JPEG

    public static final int JPEG
    JPEG

    See Also:
    Constant Field Values

    PNG

    public static final int PNG
    PNG

    See Also:
    Constant Field Values

    DIB

    public static final int DIB
    Windows DIB (BMP)

    See Also:
    Constant Field Values

    HEADER_SIZE

    public static final int HEADER_SIZE
    The size of the header

    See Also:
    Constant Field Values

    pictdata

    protected byte[] pictdata
    Binary data of the picture


    header

    protected byte[] header
    Header which holds information about this picture

    Constructor Detail

    Picture

    public Picture(byte[] pictstream,
                   int offset)
    Read a picture from "Pictures" OLE stream

    Parameters:
    pictstream - the bytes to read
    offset - the index of the first byte to read
    Method Detail

    getData

    public byte[] getData()
    Returns:
    the binary data of this picture

    getSize

    public int getSize()
    Return image size in bytes

    Returns:
    the size of the picture in bytes

    getUID

    public byte[] getUID()
    Returns the unique identifier (UID) of this picture. The UID is a checksum of the picture data. Its length is 16 bytes and it must be unique across the presentation.

    Returns:
    the unique identifier of this picture

    getType

    public int getType()
    Returns the type of this picture. Must be one of the static constans defined in this class.

    Returns:
    type of this picture.


    Copyright 2006 The Apache Software Foundation or its licensors, as applicable.