org.apache.poi.hwpf.usermodel
Class Picture

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

public class Picture
extends java.lang.Object

Represents embedded picture extracted from Word Document

Author:
Dmitry Romanov

Field Summary
static byte[] BMP
           
static byte[] COMPRESSED1
           
static byte[] COMPRESSED2
           
static byte[] EMF
           
static byte[] GIF
           
static byte[] IHDR
           
static byte[] JPG
           
static byte[] PNG
           
static byte[] TIFF
           
static byte[] TIFF1
           
static byte[] WMF1
           
static byte[] WMF2
           
 
Constructor Summary
Picture(byte[] _dataStream)
           
Picture(int dataBlockStartOfsset, byte[] _dataStream, boolean fillBytes)
           
 
Method Summary
 int getAspectRatioX()
          returns horizontal aspect ratio for picture provided by user
 int getAspectRatioY()
          returns vertical aspect ratio for picture provided by user
 byte[] getContent()
           
 int getHeight()
          returns pixel height of the picture or -1 if dimensions determining was failed
 byte[] getRawContent()
           
 int getSize()
           
 int getWidth()
          returns pixel width of the picture or -1 if dimensions determining was failed
 java.lang.String suggestFileExtension()
          tries to suggest extension for picture's file by matching signatures of popular image formats to first bytes of picture's contents
 java.lang.String suggestFullFileName()
          Tries to suggest a filename: hex representation of picture structure offset in "Data" stream plus extension that is tried to determine from first byte of picture's content.
 void writeImageContent(java.io.OutputStream out)
          Writes Picture's content bytes to specified OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GIF

public static final byte[] GIF

PNG

public static final byte[] PNG

JPG

public static final byte[] JPG

BMP

public static final byte[] BMP

TIFF

public static final byte[] TIFF

TIFF1

public static final byte[] TIFF1

EMF

public static final byte[] EMF

WMF1

public static final byte[] WMF1

WMF2

public static final byte[] WMF2

IHDR

public static final byte[] IHDR

COMPRESSED1

public static final byte[] COMPRESSED1

COMPRESSED2

public static final byte[] COMPRESSED2
Constructor Detail

Picture

public Picture(int dataBlockStartOfsset,
               byte[] _dataStream,
               boolean fillBytes)

Picture

public Picture(byte[] _dataStream)
Method Detail

suggestFullFileName

public java.lang.String suggestFullFileName()
Tries to suggest a filename: hex representation of picture structure offset in "Data" stream plus extension that is tried to determine from first byte of picture's content.

Returns:
suggested file name

writeImageContent

public void writeImageContent(java.io.OutputStream out)
                       throws java.io.IOException
Writes Picture's content bytes to specified OutputStream. Is useful when there is need to write picture bytes directly to stream, omitting its representation in memory as distinct byte array.

Parameters:
out - a stream to write to
Throws:
java.io.IOException - if some exception is occured while writing to specified out

getContent

public byte[] getContent()
Returns:
picture's content as byte array

getRawContent

public byte[] getRawContent()

getSize

public int getSize()
Returns:
size in bytes of the picture

getAspectRatioX

public int getAspectRatioX()
returns horizontal aspect ratio for picture provided by user


getAspectRatioY

public int getAspectRatioY()
returns vertical aspect ratio for picture provided by user


suggestFileExtension

public java.lang.String suggestFileExtension()
tries to suggest extension for picture's file by matching signatures of popular image formats to first bytes of picture's contents

Returns:
suggested file extension

getWidth

public int getWidth()
returns pixel width of the picture or -1 if dimensions determining was failed


getHeight

public int getHeight()
returns pixel height of the picture or -1 if dimensions determining was failed



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