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 |
---|---|
resize(int newWidth, int newHeight, int resizeType) | Resizes the specified new width. |
resize(int newWidth, int newHeight, ImageResizeSettings settings) | Resizes the image with extended options. |
rotateFlip(int rotateFlipType) | Rotates, flips, or rotates and flips the image. |
crop(Rectangle rectangle) | Crops the specified rectangle. |
rotate(float angle) | Rotate image around the center. |
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()
resize(int newWidth, int newHeight, int resizeType)
public void resize(int newWidth, int newHeight, int resizeType)
Resizes the specified new width.
Parameters:
Parameter | Type | Description |
---|---|---|
newWidth | int | The new width. |
newHeight | int | The new height. |
resizeType | int | Type of the resize. |
resize(int newWidth, int newHeight, ImageResizeSettings settings)
public void resize(int newWidth, int newHeight, ImageResizeSettings settings)
Resizes the image with extended options.
Parameters:
Parameter | Type | Description |
---|---|---|
newWidth | int | The new width. |
newHeight | int | The new height. |
settings | ImageResizeSettings | The resize settings. |
rotateFlip(int rotateFlipType)
public void rotateFlip(int rotateFlipType)
Rotates, flips, or rotates and flips the image.
Parameters:
Parameter | Type | Description |
---|---|---|
rotateFlipType | int | Type of the rotate&flip. |
crop(Rectangle rectangle)
public void crop(Rectangle rectangle)
Crops the specified rectangle.
Parameters:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle. |
rotate(float angle)
public void rotate(float angle)
Rotate image around the center.
Parameters:
Parameter | Type | Description |
---|---|---|
angle | float | The rotate angle in degrees. Positive values will rotate clockwise. |
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 void removeBackground()
Removes the background.
removeBackground(RemoveBackgroundSettings settings)
public void removeBackground(RemoveBackgroundSettings settings)
Removes the background.
Parameters:
Parameter | Type | Description |
---|---|---|
settings | RemoveBackgroundSettings | The settings. |