org.apache.poi.hslf.usermodel
Class PictureData

java.lang.Object
  extended by org.apache.poi.hslf.usermodel.PictureData
Direct Known Subclasses:
Bitmap, Metafile

public abstract class PictureData
extends java.lang.Object

A class that represents image data contained in a slide show.

Author:
Yegor Kozlov

Field Summary
protected static int CHECKSUM_SIZE
          Size of the image checksum calculated using MD5 algorithm.
protected  POILogger logger
           
protected  int offset
          The offset to the picture in the stream
protected static ImagePainter[] painters
           
 
Constructor Summary
PictureData()
           
 
Method Summary
static PictureData create(int type)
          Create an instance of PictureData by type.
 void draw(java.awt.Graphics2D graphics, Picture parent)
           
static byte[] getChecksum(byte[] data)
          Compute 16-byte checksum of this picture using MD5 algorithm.
abstract  byte[] getData()
          Returns the binary data of this Picture
 byte[] getHeader()
          Return 24 byte header which preceeds the actual picture data.
static ImagePainter getImagePainter(int type)
          Return ImagePainter for the specified image type
 int getOffset()
          File offset in the 'Pictures' stream
 byte[] getRawData()
          Returns the raw binary data of this Picture excluding the first 8 bytes which hold image signature and size of the image data.
protected abstract  int getSignature()
          Blip signature.
 int getSize()
          Deprecated. Use getData().length instead.
abstract  int getType()
          Returns type of this picture.
 byte[] getUID()
          Returns 16-byte checksum of this picture
abstract  void setData(byte[] data)
          Set picture data
static void setImagePainter(int type, ImagePainter painter)
          Register ImagePainter for the specified image type
 void setOffset(int offset)
          Set offset of this picture in the 'Pictures' stream.
 void setRawData(byte[] data)
           
 void write(java.io.OutputStream out)
          Write this picture into OutputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected POILogger logger

CHECKSUM_SIZE

protected static final int CHECKSUM_SIZE
Size of the image checksum calculated using MD5 algorithm.

See Also:
Constant Field Values

offset

protected int offset
The offset to the picture in the stream


painters

protected static ImagePainter[] painters
Constructor Detail

PictureData

public PictureData()
Method Detail

getType

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

Returns:
type of this picture.

getData

public abstract byte[] getData()
Returns the binary data of this Picture

Returns:
picture data

setData

public abstract void setData(byte[] data)
                      throws java.io.IOException
Set picture data

Throws:
java.io.IOException

getSignature

protected abstract int getSignature()
Blip signature.


getRawData

public byte[] getRawData()
Returns the raw binary data of this Picture excluding the first 8 bytes which hold image signature and size of the image data.

Returns:
picture data

setRawData

public void setRawData(byte[] data)

getOffset

public int getOffset()
File offset in the 'Pictures' stream

Returns:
offset in the 'Pictures' stream

setOffset

public void setOffset(int offset)
Set offset of this picture in the 'Pictures' stream. We need to set it when a new picture is created.

Parameters:
offset - in the 'Pictures' stream

getUID

public byte[] getUID()
Returns 16-byte checksum of this picture


getChecksum

public static byte[] getChecksum(byte[] data)
Compute 16-byte checksum of this picture using MD5 algorithm.


write

public void write(java.io.OutputStream out)
           throws java.io.IOException
Write this picture into OutputStream

Throws:
java.io.IOException

create

public static PictureData create(int type)
Create an instance of PictureData by type.

Parameters:
type - type of the picture data. Must be one of the static constants defined in the Picture class.
Returns:
concrete instance of PictureData

getHeader

public byte[] getHeader()
Return 24 byte header which preceeds the actual picture data.

The header consists of 2-byte signature, 2-byte type, 4-byte image size and 16-byte checksum of the image data.

Returns:
the 24 byte header which preceeds the actual picture data.

getSize

public int getSize()
Deprecated. Use getData().length instead.

Return image size in bytes

Returns:
the size of the picture in bytes

draw

public void draw(java.awt.Graphics2D graphics,
                 Picture parent)

setImagePainter

public static void setImagePainter(int type,
                                   ImagePainter painter)
Register ImagePainter for the specified image type

Parameters:
type - image type, must be one of the static constants defined in the Picture class.
painter -

getImagePainter

public static ImagePainter getImagePainter(int type)
Return ImagePainter for the specified image type

Parameters:
type - blip type, must be one of the static constants defined in the Picture class.
Returns:
ImagePainter for the specified image type


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