public abstract class VectorImage extends Image implements IObjectWithSizeF
The vector image is the base class for all type of vector images.
Image,
IObjectWithSizeFThe 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);
}
| Modifier and Type | Method and Description |
|---|---|
void |
crop(Rectangle rectangle)
Crops the specified rectangle.
|
ImageOptionsBase |
getDefaultOptions(Object[] args)
Gets the default image options.
|
EmbeddedImage[] |
getEmbeddedImages()
Gets the embedded images.
|
int |
getHeight()
Gets the image height.
|
float |
getHeightF()
Gets the object height, in inches.
|
SizeF |
getSizeF()
Gets the object size, in inches.
|
int |
getWidth()
Gets the image width.
|
float |
getWidthF()
Gets the object width, in inches.
|
void |
removeBackground()
Removes the background.
|
void |
removeBackground(RemoveBackgroundSettings settings)
Removes the background.
|
void |
resize(int newWidth,
int newHeight,
ImageResizeSettings settings)
Resizes the image with extended options.
|
void |
resize(int newWidth,
int newHeight,
int resizeType)
Resizes the specified new width.
|
void |
rotate(float angle)
Rotate image around the center.
|
void |
rotateFlip(int rotateFlipType)
Rotates, flips, or rotates and flips the image.
|
canLoad, canLoad, canLoad, canLoad, canSave, create, create, create, create, create, create, crop, getBackgroundColor, getBitsPerPixel, getBounds, getBufferSizeHint, getContainer, getFileFormat, getFileFormat, getFileFormat, getFittingRectangle, getFittingRectangle, getInterruptMonitor, getIProgressEventHandler, getOriginalOptions, getPalette, getProgressEventHandlerInfo, getProportionalHeight, getProportionalWidth, getSerializedStream, getSize, hasBackgroundColor, isAutoAdjustPalette, isUsePalette, load, load, load, load, load, load, removeMetadata, resize, resizeHeightProportionally, resizeHeightProportionally, resizeHeightProportionally, resizeWidthProportionally, resizeWidthProportionally, resizeWidthProportionally, save, save, save, save, save, save, save, save, setAutoAdjustPalette, setBackgroundColor, setBackgroundColor, setBufferSizeHint, setInterruptMonitor, setPalette, setPalettecacheData, getDataStreamContainer, isCached, save, save, saveclose, dispose, getDisposedpublic void resize(int newWidth,
int newHeight,
int resizeType)
Resizes the specified new width.
public void resize(int newWidth,
int newHeight,
ImageResizeSettings settings)
Resizes the image with extended options.
public void rotateFlip(int rotateFlipType)
Rotates, flips, or rotates and flips the image.
rotateFlip in class ImagerotateFlipType - Type of the rotate&flip.com.aspose.ms.System.ArgumentOutOfRangeException - Incorrect the type of the rotate&flip.RotateFlipTypepublic void crop(Rectangle rectangle)
Crops the specified rectangle.
public void rotate(float angle)
Rotate image around the center.
public final SizeF getSizeF()
Gets the object size, in inches.
getSizeF in interface IObjectWithSizeFpublic float getWidthF()
Gets the object width, in inches.
getWidthF in interface IObjectWithSizeFpublic float getHeightF()
Gets the object height, in inches.
getHeightF in interface IObjectWithSizeFpublic int getWidth()
Gets the image width.
getWidth in interface IObjectWithBoundsgetWidth in class Imagepublic int getHeight()
Gets the image height.
getHeight in interface IObjectWithBoundsgetHeight in class Imagepublic ImageOptionsBase getDefaultOptions(Object[] args)
Gets the default image options.
getDefaultOptions in class Imageargs - The arguments.public EmbeddedImage[] getEmbeddedImages()
Gets the embedded images.
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();
}
}
}
public void removeBackground()
Removes the background.
public void removeBackground(RemoveBackgroundSettings settings)
Removes the background.
settings - The settings.Copyright (c) 2008-2025 Aspose Pty Ltd. All Rights Reserved.