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.
|
getHeightF, getSizeF, getWidthF
canLoad, canLoad, canLoad, canLoad, canSave, create, getBackgroundColor, getBounds, getBufferSizeHint, getContainer, getFileFormat, getFileFormat, getFittingRectangle, getFittingRectangle, getInterruptMonitor, getOriginalOptions, getPalette, getProgressEventHandler, getProgressEventHandlerInfo, getProportionalHeight, getProportionalWidth, getSize, hasBackgroundColor, isAutoAdjustPalette, load, load, load, load, load, load, resize, resizeHeightProportionally, resizeHeightProportionally, resizeHeightProportionally, resizeWidthProportionally, resizeWidthProportionally, resizeWidthProportionally, save, save, save, save, save, save, save, setAutoAdjustPalette, setBackgroundColor, setBackgroundColor, setBufferSizeHint, setInterruptMonitor, setPalette
getDataStreamContainer, save, save, save, save
close, dispose, getDisposed
public 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 DataStreamSupporter
true
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 Image
com.aspose.ms.System.NotImplementedException
- Not valid for vector imagespublic int getHeight()
Gets the image height.
getHeight
in interface IObjectWithBounds
getHeight
in class VectorImage
public int getWidth()
Gets the image width.
getWidth
in interface IObjectWithBounds
getWidth
in class VectorImage
public long getFileFormat()
Gets a value of file format
getFileFormat
in class Image
public ImageOptionsBase getDefaultOptions(Object[] args)
Gets the default options.
getDefaultOptions
in class Image
args
- 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 DataStreamSupporter
public 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 Image
rotateFlipType
- Type of the rotate flip.com.aspose.ms.System.NotImplementedException
- this feature is not implementedpublic void setPalette(IColorPalette palette, boolean updateColors)
Sets the image palette.
setPalette
in class Image
palette
- 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 implemented