public final class SvgImage extends VectorImage
Represents SVG image class.
This example shows how to load an SVG image from a file stream and rasterize it to PNG.
String dir = "c:\\temp\\";
// Load an SVG image from a file stream.
java.io.InputStream stream = new java.io.FileInputStream(dir + "test.svg");
com.aspose.imaging.fileformats.svg.SvgImage svgImage = new com.aspose.imaging.fileformats.svg.SvgImage(stream);
try {
// In order to rasterize SVG we need to specify rasterization options.
com.aspose.imaging.imageoptions.SvgRasterizationOptions rasterizationOptions = new com.aspose.imaging.imageoptions.SvgRasterizationOptions();
com.aspose.imaging.imageoptions.PngOptions saveOptions = new com.aspose.imaging.imageoptions.PngOptions();
saveOptions.setVectorRasterizationOptions(rasterizationOptions);
svgImage.save(dir + "test.output.png", saveOptions);
} finally {
svgImage.dispose();
stream.close();
}
| Constructor and Description |
|---|
SvgImage(InputStream stream)
Initializes a new instance of the
SvgImage class. |
SvgImage(int width,
int height)
Initializes a new instance of the
SvgImage class. |
SvgImage(String path)
Initializes a new instance of the
SvgImage class. |
SvgImage(SvgOptions svgOptions,
int width,
int height)
Initializes a new instance of the
SvgImage class. |
| Modifier and Type | Method and Description |
|---|---|
void |
cacheData()
Caches the data and ensures no additional data loading will be performed from the underlying
DataStreamSupporter.DataStreamContainer. |
int |
getBitsPerPixel()
Gets the image bits per pixel count this parameter is not applicable to vector images
|
ImageOptionsBase |
getDefaultOptions(Object[] args)
Gets the default options.
|
long |
getFileFormat()
Gets a value of file format
|
int |
getHeight()
Gets the image height.
|
int |
getWidth()
Gets the image width.
|
boolean |
isCached()
Gets a value indicating whether object's data is cached currently and no data reading is required.
|
void |
resize(int newWidth,
int newHeight,
ImageResizeSettings settings)
Resizes the image.
|
void |
resize(int newWidth,
int newHeight,
int resizeType)
Resizes the image.
|
void |
rotateFlip(int rotateFlipType)
Rotates, flips, or rotates and flips the image.
|
void |
setPalette(IColorPalette palette,
boolean updateColors)
Sets the image palette.
|
getEmbeddedImages, getHeightF, getSizeF, getWidthFcanLoad, canLoad, canLoad, canLoad, canSave, create, create, create, getBackgroundColor, getBounds, getBufferSizeHint, getContainer, getFileFormat, getFileFormat, getFittingRectangle, getFittingRectangle, getInterruptMonitor, getOriginalOptions, getPalette, getProgressEventHandler, getProgressEventHandlerInfo, getProportionalHeight, getProportionalWidth, getSize, hasBackgroundColor, isAutoAdjustPalette, isUsePalette, load, load, load, load, load, load, resize, resizeHeightProportionally, resizeHeightProportionally, resizeHeightProportionally, resizeWidthProportionally, resizeWidthProportionally, resizeWidthProportionally, save, save, save, save, save, save, save, save, setAutoAdjustPalette, setBackgroundColor, setBackgroundColor, setBufferSizeHint, setInterruptMonitor, setPalettegetDataStreamContainer, save, save, saveclose, dispose, getDisposedpublic SvgImage(String path)
Initializes a new instance of the SvgImage class.
path - The path to load image from and initialize pixel and palette data with.com.aspose.ms.System.ArgumentNullException - path is null.public SvgImage(InputStream stream)
Initializes a new instance of the SvgImage class.
stream - The stream to load image from and initialize pixel and palette data with.com.aspose.ms.System.ArgumentNullException - stream is null.This example shows how to load an SVG image from a file stream and rasterize it to PNG.
String dir = "c:\\temp\\";
// Load an SVG image from a file stream.
java.io.InputStream stream = new java.io.FileInputStream(dir + "test.svg");
com.aspose.imaging.fileformats.svg.SvgImage svgImage = new com.aspose.imaging.fileformats.svg.SvgImage(stream);
try {
// In order to rasterize SVG we need to specify rasterization options.
com.aspose.imaging.imageoptions.SvgRasterizationOptions rasterizationOptions = new com.aspose.imaging.imageoptions.SvgRasterizationOptions();
com.aspose.imaging.imageoptions.PngOptions saveOptions = new com.aspose.imaging.imageoptions.PngOptions();
saveOptions.setVectorRasterizationOptions(rasterizationOptions);
svgImage.save(dir + "test.output.png", saveOptions);
} finally {
svgImage.dispose();
stream.close();
}
public SvgImage(int width,
int height)
Initializes a new instance of the SvgImage class.
width - The image width.height - The image height.public SvgImage(SvgOptions svgOptions, int width, int height)
Initializes a new instance of the SvgImage class.
svgOptions - The SVG options.width - Image width.height - Image height.public boolean isCached()
Gets a value indicating whether object's data is cached currently and no data reading is required.
isCached in class DataStreamSupportertrue if object's data is cached; otherwise, false.public int getBitsPerPixel()
Gets the image bits per pixel count this parameter is not applicable to vector images
getBitsPerPixel in class Imagecom.aspose.ms.System.NotImplementedException - Not valid for vector imagespublic int getHeight()
Gets the image height.
getHeight in interface IObjectWithBoundsgetHeight in class VectorImagepublic int getWidth()
Gets the image width.
getWidth in interface IObjectWithBoundsgetWidth in class VectorImagepublic long getFileFormat()
Gets a value of file format
getFileFormat in class ImageFileFormatpublic ImageOptionsBase getDefaultOptions(Object[] args)
Gets the default options.
getDefaultOptions in class Imageargs - The arguments.public void cacheData()
Caches the data and ensures no additional data loading will be performed from the underlying DataStreamSupporter.DataStreamContainer.
cacheData in class DataStreamSupporterpublic void resize(int newWidth,
int newHeight,
int resizeType)
Resizes the image.
public void resize(int newWidth,
int newHeight,
ImageResizeSettings settings)
Resizes the image.
public void rotateFlip(int rotateFlipType)
Rotates, flips, or rotates and flips the image.
rotateFlip in class ImagerotateFlipType - Type of the rotating flip.com.aspose.ms.System.NotImplementedException - this feature is not implementedpublic void setPalette(IColorPalette palette, boolean updateColors)
Sets the image palette.
setPalette in class Imagepalette - The palette to set.updateColors - if set to true colors will be updated according to the new palette; otherwise color indexes remain unchanged. Note that unchanged indexes may crash the image on loading if some indexes have no corresponding palette entries.com.aspose.ms.System.NotImplementedException - if not implementedCopyright (c) 2008-2022 Aspose Pty Ltd. All Rights Reserved.