public interface IImageData
You can use this interface if you want to process images stored in a document (e.g. extract or replace)
and you want to do that using the same code both for images stored in "old" VML-based and "new" DrawingML-based shapes. Documents created by Microsoft Word 2003 or earlier had one type of graphical objects.
These objects were VML (Vector Markup Language) based. In the Aspose.Words document model such objects are represented
by the Documents created by Microsoft Word 2007 or newer can have two types of graphical objects.
The old VML-based shapes and also the new DrawingML-based shapes. DrawingML is part of the Office Open XML standard.
In the Aspose.Words document model the new DrawingML-based shapes are represented by the The
Property Getters/Setters Summary | ||
---|---|---|
abstract boolean | hasImage() | |
Returns true if the shape has image bytes or links an image. | ||
abstract byte[] | getImageBytes() | |
abstract void | setImageBytes(byte[] value) | |
Gets or sets the raw bytes of the image stored in the shape. | ||
abstract ImageSize | getImageSize() | |
Gets the information about image size and resolution. | ||
abstract int | getImageType() | |
Gets the type of the image. The value of the property is ImageType integer constant. | ||
abstract boolean | isLink() | |
Returns true if the image is linked to the shape (when |
||
abstract boolean | isLinkOnly() | |
Returns true if the image is linked and not stored in the document. | ||
abstract java.lang.String | getSourceFullName() | |
abstract void | setSourceFullName(java.lang.String value) | |
Gets or sets the path and name of the source file for the linked image. |
Method Summary | ||
---|---|---|
abstract void | save(java.io.OutputStream stream) | |
Saves the image into the specified stream. | ||
abstract void | save(java.lang.String fileName) | |
Saves the image into a file. | ||
abstract void | setImage(java.awt.image.BufferedImage image) | |
Sets the image that the shape displays. | ||
abstract void | setImage(java.io.InputStream stream) | |
Sets the image that the shape displays. | ||
abstract void | setImage(java.lang.String fileName) | |
Sets the image that the shape displays. | ||
abstract byte[] | toByteArray() | |
Returns image bytes for any image regardless whether the image is stored or linked. | ||
abstract java.awt.image.BufferedImage | toImage() | |
Gets the image stored in the shape as a java BufferedImage object. |
Property Getters/Setters Detail |
---|
hasImage | |
public abstract boolean hasImage() |
getImageBytes/setImageBytes | |
public abstract byte[] getImageBytes() / public abstract void setImageBytes(byte[] value) |
Setting the value to null
or an empty array will remove the image from the shape.
Returns null
if the image is not stored in the document (e.g the image is probably linked in this case).
getImageSize | |
public abstract ImageSize getImageSize() |
If the image is linked only and not stored in the document, returns zero size.
getImageType | |
public abstract int getImageType() |
isLink | |
public abstract boolean isLink() |
isLinkOnly | |
public abstract boolean isLinkOnly() |
getSourceFullName/setSourceFullName | |
public abstract java.lang.String getSourceFullName() / public abstract void setSourceFullName(java.lang.String value) |
The default value is an empty string.
If
If null
,
then the image is linked and not stored in the document.
Method Detail |
---|
save | |
public abstract void save(java.io.OutputStream stream) throws java.lang.Exception |
Is it the responsibility of the caller to dispose the stream object.
stream
- The stream where to save the image to.save | |
public abstract void save(java.lang.String fileName) throws java.lang.Exception |
fileName
- The file name where to save the image.setImage | |
public abstract void setImage(java.awt.image.BufferedImage image) throws java.lang.Exception |
image
- The image object.setImage | |
public abstract void setImage(java.io.InputStream stream) throws java.lang.Exception |
stream
- The stream that contains the image.
The stream will be read from the current position.setImage | |
public abstract void setImage(java.lang.String fileName) throws java.lang.Exception |
fileName
- The image file. Can be a file name or a URL.toByteArray | |
public abstract byte[] toByteArray() throws java.lang.Exception |
If the image is linked, downloads the image every time it is called.
toImage | |
public abstract java.awt.image.BufferedImage toImage() throws java.lang.Exception |
Tries to create a new java.awt.image.BufferedImage object from image bytes every time this method is called. If javax.imageio.ImageReader can't read image bytes (emf, wmf, tiff, etc.) the method returns null.
It is the responsibility of the caller to dispose the image object.