Package org.apache.poi.xslf.usermodel
Class XSLFPictureData
java.lang.Object
org.apache.poi.ooxml.POIXMLDocumentPart
org.apache.poi.xslf.usermodel.XSLFPictureData
- All Implemented Interfaces:
PictureData
Instantiates sub-classes of POIXMLDocumentPart depending on their relationship type
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPartNested classes/interfaces inherited from interface org.apache.poi.sl.usermodel.PictureData
PictureData.PictureType -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreate a new XSLFGraphicData nodeXSLFPictureData(PackagePart part) Construct XSLFPictureData from a package part -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDetermine and cache image propertiesbyte[]Gets the checksum - the checksum can be of various length - mostly it's 8 (XSLF) or 16 (HSLF) bytes long.Returns content type (mime type) of this picture.byte[]getData()Gets the picture data as a byte array.Returns the file name of the image, eg image7.jpg .Return the original image dimensions in points (for formats supported by BufferedImage).Return the original image dimensions in pixelsintgetIndex()An InputStream to read the picture data directly from the underlying package partgetType()protected void*PictureData objects store the actual content in the part directly without keeping a copy like all others therefore we need to handle them differently.voidsetData(byte[] data) Sets the binary picture datavoidsetIndex(int index) Suggests a file extension for this image.Methods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, commit, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommited, onDocumentCreate, onDocumentRead, onDocumentRemove, onSave, read, rebase, removeRelation, removeRelation, removeRelation, setCommited, toString
-
Constructor Details
-
XSLFPictureData
protected XSLFPictureData()Create a new XSLFGraphicData node -
XSLFPictureData
Construct XSLFPictureData from a package part- Parameters:
part- the package part holding the drawing data- Since:
- POI 3.14-Beta1
-
-
Method Details
-
getInputStream
An InputStream to read the picture data directly from the underlying package part- Returns:
- InputStream
- Throws:
IOException
-
getData
public byte[] getData()Gets the picture data as a byte array. You can grab the picture data directly from the underlying package part with thegetInputStream()method- Specified by:
getDatain interfacePictureData- Returns:
- the Picture data.
-
getFileName
Returns the file name of the image, eg image7.jpg . The original filename isn't always available, but if it can be found it's likely to be in the CTDrawing -
suggestFileExtension
Suggests a file extension for this image.- Returns:
- the file extension.
-
getChecksum
public byte[] getChecksum()Description copied from interface:PictureDataGets the checksum - the checksum can be of various length - mostly it's 8 (XSLF) or 16 (HSLF) bytes long.- Specified by:
getChecksumin interfacePictureData- Returns:
- the checksum
-
getImageDimension
Description copied from interface:PictureDataReturn the original image dimensions in points (for formats supported by BufferedImage). Will return a Dimension with a default width of 200x200 if the format unsupported.- Specified by:
getImageDimensionin interfacePictureData
-
getImageDimensionInPixels
Description copied from interface:PictureDataReturn the original image dimensions in pixels- Specified by:
getImageDimensionInPixelsin interfacePictureData- See Also:
-
cacheProperties
protected void cacheProperties()Determine and cache image properties -
prepareForCommit
protected void prepareForCommit()*PictureData objects store the actual content in the part directly without keeping a copy like all others therefore we need to handle them differently.- Overrides:
prepareForCommitin classPOIXMLDocumentPart
-
getContentType
Description copied from interface:PictureDataReturns content type (mime type) of this picture.- Specified by:
getContentTypein interfacePictureData- Returns:
- content type of this picture.
-
setData
Description copied from interface:PictureDataSets the binary picture data- Specified by:
setDatain interfacePictureData- Parameters:
data- picture data- Throws:
IOException
-
getType
- Specified by:
getTypein interfacePictureData- Returns:
- the picture type
-
getIndex
public int getIndex()- Returns:
- the 0-based index of this pictures within the picture parts
-
setIndex
public void setIndex(int index) - Parameters:
index- sets the 0-based index of this pictures within the picture parts
-