org.apache.poi.hwpf.usermodel
Class Picture

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

public final class Picture
extends PictureDescriptor

Represents embedded picture extracted from Word Document

Author:
Dmitry Romanov

Field Summary
static byte[] BMP
          Deprecated. 
static byte[] COMPRESSED1
           
static byte[] COMPRESSED2
           
static byte[] EMF
          Deprecated. 
static byte[] GIF
          Deprecated. 
static byte[] IHDR
           
static byte[] JPG
          Deprecated. 
static byte[] PNG
          Deprecated. 
static byte[] TIFF
          Deprecated. 
static byte[] TIFF1
          Deprecated. 
static byte[] WMF1
          Deprecated. 
static byte[] WMF2
          Deprecated. 
 
Fields inherited from class org.apache.poi.hwpf.model.PictureDescriptor
cbHeader, dxaCropLeft, dxaCropRight, dxaGoal, dyaCropBottom, dyaCropTop, dyaGoal, lcb, mfp_hMF, mfp_mm, mfp_xExt, mfp_yExt, mx, my, offset14
 
Constructor Summary
Picture(byte[] _dataStream)
           
Picture(int dataBlockStartOfsset, byte[] _dataStream, boolean fillBytes)
           
 
Method Summary
 int getAspectRatioX()
          Deprecated. use more precise getHorizontalScalingFactor()
 int getAspectRatioY()
          Deprecated. use more precise getVerticalScalingFactor()
 byte[] getContent()
           
 int getDxaCropLeft()
           
 int getDxaCropRight()
           
 int getDxaGoal()
          Gets the initial width of the picture, in twips, prior to cropping or scaling.
 int getDyaCropBottom()
           
 int getDyaCropTop()
           
 int getDyaGoal()
          Gets the initial height of the picture, in twips, prior to cropping or scaling.
 int getHeight()
          returns pixel height of the picture or -1 if dimensions determining was failed
 int getHorizontalScalingFactor()
           
 java.lang.String getMimeType()
          Returns the MIME type for the image
 byte[] getRawContent()
          Returns picture's content as it stored in Word file, i.e.
 int getSize()
           
 int getStartOffset()
           
 int getVerticalScalingFactor()
           
 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.
 PictureType suggestPictureType()
           
 void writeImageContent(java.io.OutputStream out)
          Writes Picture's content bytes to specified OutputStream.
 
Methods inherited from class org.apache.poi.hwpf.model.PictureDescriptor
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GIF

@Deprecated
public static final byte[] GIF
Deprecated. 

PNG

@Deprecated
public static final byte[] PNG
Deprecated. 

JPG

@Deprecated
public static final byte[] JPG
Deprecated. 

BMP

@Deprecated
public static final byte[] BMP
Deprecated. 

TIFF

@Deprecated
public static final byte[] TIFF
Deprecated. 

TIFF1

@Deprecated
public static final byte[] TIFF1
Deprecated. 

EMF

@Deprecated
public static final byte[] EMF
Deprecated. 

WMF1

@Deprecated
public static final byte[] WMF1
Deprecated. 

WMF2

@Deprecated
public static final byte[] WMF2
Deprecated. 

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

getStartOffset

public int getStartOffset()
Returns:
The offset of this picture in the picture bytes, used when matching up with CharacterRun.getPicOffset()

getContent

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

getRawContent

public byte[] getRawContent()
Returns picture's content as it stored in Word file, i.e. possibly in compressed form.

Returns:
picture's content as it stored in Word file

getSize

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

getAspectRatioX

@Deprecated
public int getAspectRatioX()
Deprecated. use more precise getHorizontalScalingFactor()

Returns:
the horizontal aspect ratio for picture provided by user

getHorizontalScalingFactor

public int getHorizontalScalingFactor()
Returns:
Horizontal scaling factor supplied by user expressed in .001% units

getAspectRatioY

@Deprecated
public int getAspectRatioY()
Deprecated. use more precise getVerticalScalingFactor()


getVerticalScalingFactor

public int getVerticalScalingFactor()
Returns:
Vertical scaling factor supplied by user expressed in .001% units

getDxaGoal

public int getDxaGoal()
Gets the initial width of the picture, in twips, prior to cropping or scaling.

Returns:
the initial width of the picture in twips

getDyaGoal

public int getDyaGoal()
Gets the initial height of the picture, in twips, prior to cropping or scaling.

Returns:
the initial width of the picture in twips

getDxaCropLeft

public int getDxaCropLeft()
Returns:
The amount the picture has been cropped on the left in twips

getDyaCropTop

public int getDyaCropTop()
Returns:
The amount the picture has been cropped on the top in twips

getDxaCropRight

public int getDxaCropRight()
Returns:
The amount the picture has been cropped on the right in twips

getDyaCropBottom

public int getDyaCropBottom()
Returns:
The amount the picture has been cropped on the bottom in twips

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

getMimeType

public java.lang.String getMimeType()
Returns the MIME type for the image

Returns:
MIME-type for known types of image or "image/unknown" if unknown

suggestPictureType

public PictureType suggestPictureType()

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 2011 The Apache Software Foundation or its licensors, as applicable.