VectorRasterizationOptions.PageSize
Contents
[
Hide
]VectorRasterizationOptions.PageSize property
Gets or sets the page size.
public SizeF PageSize { get; set; }
Examples
This example shows how to load a WMF image from a file and convert it to SVG using WmfRasterizationOptions.
[C#]
string dir = "c:\\temp\\";
// Using Aspose.Imaging.Image.Load is a unified way to load all types of images including WMF.
using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = (Aspose.Imaging.FileFormats.Wmf.WmfImage)Aspose.Imaging.Image.Load(dir + "test.wmf"))
{
Aspose.Imaging.ImageOptions.SvgOptions saveOptions = new Aspose.Imaging.ImageOptions.SvgOptions();
// Text will be converted to shapes.
saveOptions.TextAsShapes = true;
Aspose.Imaging.ImageOptions.WmfRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.WmfRasterizationOptions();
// The background color of the drawing surface.
rasterizationOptions.BackgroundColor = Aspose.Imaging.Color.WhiteSmoke;
// The page size.
rasterizationOptions.PageSize = wmfImage.Size;
// If embedded emf exists, then render emf; otherwise render wmf.
rasterizationOptions.RenderMode = Aspose.Imaging.FileFormats.Wmf.WmfRenderMode.Auto;
saveOptions.VectorRasterizationOptions = rasterizationOptions;
wmfImage.Save(dir + "test.output.svg", saveOptions);
}
This example shows how to load a EMF image from a file and convert it to SVG using EmfRasterizationOptions.
[C#]
string dir = "c:\\temp\\";
// Using Aspose.Imaging.Image.Load is a unified way to load all types of images including EMF.
using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = (Aspose.Imaging.FileFormats.Emf.EmfImage)Aspose.Imaging.Image.Load(dir + "test.emf"))
{
Aspose.Imaging.ImageOptions.SvgOptions saveOptions = new Aspose.Imaging.ImageOptions.SvgOptions();
// Text will be converted to shapes.
saveOptions.TextAsShapes = true;
Aspose.Imaging.ImageOptions.EmfRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.EmfRasterizationOptions();
// The background color of the drawing surface.
rasterizationOptions.BackgroundColor = Aspose.Imaging.Color.WhiteSmoke;
// The page size.
rasterizationOptions.PageSize = emfImage.Size;
// If embedded emf exists, then render emf; otherwise render wmf.
rasterizationOptions.RenderMode = Aspose.Imaging.FileFormats.Emf.EmfRenderMode.Auto;
// Set the horizontal margin
rasterizationOptions.BorderX = 50;
// Set the vertical margin
rasterizationOptions.BorderY = 50;
saveOptions.VectorRasterizationOptions = rasterizationOptions;
emfImage.Save(dir + "test.output.svg", saveOptions);
}
This example shows how to load an SVG image from a file and rasterize it to PNG using various options.
[C#]
string dir = "c:\\temp\\";
// Using Aspose.Imaging.Image.Load is a unified way to load image.
using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = (Aspose.Imaging.FileFormats.Svg.SvgImage)Aspose.Imaging.Image.Load(dir + "test.svg"))
{
// In order to rasterize SVG we need to specify rasterization options.
Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
// Set default color of a background for an image. Default value is white.
rasterizationOptions.BackgroundColor = Aspose.Imaging.Color.Gray;
// Set the page size
rasterizationOptions.PageSize = svgImage.Size;
// Antialiasing is applied to lines and curves and the edges of filled areas.
rasterizationOptions.SmoothingMode = Aspose.Imaging.SmoothingMode.AntiAlias;
// Each character is drawn using its antialiased glyph bitmap without hinting.
rasterizationOptions.TextRenderingHint = Aspose.Imaging.TextRenderingHint.AntiAlias;
// Reduce the image size 10 times, i.e. the output size will be 10% of the original size.
rasterizationOptions.ScaleX = 0.1f;
rasterizationOptions.ScaleY = 0.1f;
Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
saveOptions.VectorRasterizationOptions = rasterizationOptions;
// Save to a PNG file
svgImage.Save(dir + "test.output.png", saveOptions);
}
See Also
- struct SizeF
- class VectorRasterizationOptions
- namespace Aspose.Imaging.ImageOptions
- assembly Aspose.Imaging