VectorImage
Inheritance: java.lang.Object, com.aspose.imaging.DisposableObject, com.aspose.imaging.DataStreamSupporter, com.aspose.imaging.Image
All Implemented Interfaces: com.aspose.imaging.interfaces.IObjectWithSizeF
public abstract class VectorImage extends Image implements IObjectWithSizeF
The vector image is the base class for all type of vector images.
Constructors
Constructor | Description |
---|---|
VectorImage() |
Methods
Method | Description |
---|---|
getSizeF() | Gets the object size, in inches. |
getWidthF() | Gets the object width, in inches. |
getHeightF() | Gets the object height, in inches. |
getWidth() | Gets the image width. |
getHeight() | Gets the image height. |
getEmbeddedImages() | Gets the embedded images. |
removeBackground() | Removes the background. |
removeBackground(RemoveBackgroundSettings settings) | Removes the background. |
Example: The following example shows how to export a multipage vector image to another format in general way without referencing to a particular image type.
String dir = "C:\\aspose.imaging\\java\\misc\\ImagingReleaseQATester\\Tests\\testdata\\2548\\";
String inputFilePath = dir + "Multipage.cdr";
String outputFilePath = dir + "Multipage.cdr.tif";
com.aspose.imaging.ImageOptionsBase exportOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default);
try(com.aspose.imaging.Image image = com.aspose.imaging.Image.load(inputFilePath))
{
exportOptions.setMultiPageOptions(null);
// Export only first two pages
com.aspose.imaging.IMultipageImage multipageImage = image instanceof com.aspose.imaging.IMultipageImage ? (com.aspose.imaging.IMultipageImage)image : null;
if (multipageImage != null && (multipageImage.getPages() != null && multipageImage.getPageCount() > 2))
{
exportOptions.setMultiPageOptions(new com.aspose.imaging.imageoptions.MultiPageOptions(new com.aspose.imaging.IntRange(0, 2)));
}
if (image instanceof com.aspose.imaging.VectorImage)
{
com.aspose.imaging.imageoptions.VectorRasterizationOptions defaultOptions = (com.aspose.imaging.imageoptions.VectorRasterizationOptions) image.getDefaultOptions(new Object[]{Color.getWhite(), image.getWidth(), image.getHeight()});
exportOptions.setVectorRasterizationOptions(defaultOptions);
defaultOptions.setTextRenderingHint(com.aspose.imaging.TextRenderingHint.SingleBitPerPixel);
defaultOptions.setSmoothingMode(com.aspose.imaging.SmoothingMode.None);
}
image.save(outputFilePath, exportOptions);
}
VectorImage()
public VectorImage()
getSizeF()
public final SizeF getSizeF()
Gets the object size, in inches.
Returns: SizeF - the object size, in inches.
getWidthF()
public float getWidthF()
Gets the object width, in inches.
Returns: float - the object width, in inches.
getHeightF()
public float getHeightF()
Gets the object height, in inches.
Returns: float - the object height, in inches.
getWidth()
public int getWidth()
Gets the image width.
Returns: int - the image width.
getHeight()
public int getHeight()
Gets the image height.
Returns: int - the image height.
getEmbeddedImages()
public EmbeddedImage[] getEmbeddedImages()
Gets the embedded images.
Returns: com.aspose.imaging.EmbeddedImage[] - Array of images
Example: Support extracting embedded raster images from a vector image
String inputFileName = "test.cdr";
try (Image image = com.aspose.imaging.Image.load(inputFileName))
{
com.aspose.imaging.VectorImage vectorImage = ((com.aspose.imaging.VectorImage) image);
EmbeddedImage[] images = vectorImage.getEmbeddedImages();
for (int i = 0; i < images.length; i++)
{
String outFileName = String.format("image%d.png", i++);
try
{
images[i].getImage().save(outFileName, new PngOptions());
}
finally
{
images[i].close();
}
}
}
removeBackground()
public final void removeBackground()
Removes the background.
removeBackground(RemoveBackgroundSettings settings)
public final void removeBackground(RemoveBackgroundSettings settings)
Removes the background.
Parameters:
Parameter | Type | Description |
---|---|---|
settings | RemoveBackgroundSettings | The settings. |