Package org.apache.poi.hwpf.usermodel
Class Picture
java.lang.Object
org.apache.poi.hwpf.usermodel.Picture
Represents embedded picture extracted from Word Document
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte[]
static final byte[]
static final byte[]
-
Constructor Summary
ConstructorsConstructorDescriptionPicture
(int dataBlockStartOfsset, byte[] _dataStream, boolean fillBytes) Builds a Picture object for a Picture stored in the DataStreamPicture
(EscherBlipRecord blipRecord) Builds a Picture object for a Picture stored as Escher. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
returns the description stored in the alternative textint
Deprecated.POI 3.8 beta 4.int
Deprecated.POI 3.8 beta 4.int
Gets the initial width of the picture, in twips, prior to cropping or scaling.int
Deprecated.POI 3.8 beta 5.int
Deprecated.POI 3.8 beta 5.int
Gets the initial height of the picture, in twips, prior to cropping or scaling.int
returns pixel height of the picture or -1 if dimensions determining was failedint
Returns the MIME type for the imagebyte[]
Returns picture's content as stored in the Word file, i.e.int
getSize()
int
int
int
getWidth()
returns pixel width of the picture or -1 if dimensions determining was failedtries to suggest extension for picture's file by matching signatures of popular image formats to first bytes of picture's contentsTries 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
Writes Picture's content bytes to specified OutputStream.
-
Field Details
-
COMPRESSED1
public static final byte[] COMPRESSED1 -
COMPRESSED2
public static final byte[] COMPRESSED2 -
IHDR
public static final byte[] IHDR
-
-
Constructor Details
-
Picture
Builds a Picture object for a Picture stored as Escher. TODO We need to pass in the PICF data too somehow! -
Picture
public Picture(int dataBlockStartOfsset, byte[] _dataStream, boolean fillBytes) Builds a Picture object for a Picture stored in the DataStream
-
-
Method Details
-
getContent
public byte[] getContent()- Returns:
- picture's content as byte array
-
getDxaCropLeft
Deprecated.POI 3.8 beta 4.- Returns:
- The amount the picture has been cropped on the left in twips
-
getDxaCropRight
Deprecated.POI 3.8 beta 4.- Returns:
- The amount the picture has been cropped on the right in twips
-
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
-
getDyaCropBottom
Deprecated.POI 3.8 beta 5.- Returns:
- The amount the picture has been cropped on the bottom in twips
-
getDyaCropTop
Deprecated.POI 3.8 beta 5.- Returns:
- The amount the picture has been cropped on the top 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
-
getHeight
public int getHeight()returns pixel height of the picture or -1 if dimensions determining was failed -
getHorizontalScalingFactor
public int getHorizontalScalingFactor()- Returns:
- Horizontal scaling factor supplied by user expressed in .001% units
-
getMimeType
Returns the MIME type for the image- Returns:
- MIME-type for known types of image or "image/unknown" if unknown
-
getRawContent
public byte[] getRawContent()Returns picture's content as stored in the Word file, i.e. possibly in compressed form.- Returns:
- picture's content as it stored in Word file or an empty byte array if it cannot be read.
-
getSize
public int getSize()- Returns:
- size in bytes of the picture
-
getStartOffset
public int getStartOffset()- Returns:
- The offset of this picture in the picture bytes, used when
matching up with
CharacterRun.getPicOffset()
-
getVerticalScalingFactor
public int getVerticalScalingFactor()- Returns:
- Vertical scaling factor supplied by user expressed in .001% units
-
getWidth
public int getWidth()returns pixel width of the picture or -1 if dimensions determining was failed -
getDescription
returns the description stored in the alternative text- Returns:
- pictue description
-
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
-
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
-
suggestPictureType
-
writeImageContent
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:
IOException
- if some exception is occured while writing to specified out
-