This version of Aspose.SVG for .NET (MSI installer) empowers developers with enhanced SVG rendering capabilities and seamless integration with SkiaSharp
.
Direct Rendering to SKCanvas
Integrate direct rendering to SKCanvas
within your C# apps using the latest .NET SVG library release and facilitate a more efficient and integrated workflow with SkiaSharp
. This enhancement provides greater flexibility for developers utilizing SkiaSharp’s drawing features.
The following code example demonstrates creating a SKSurface
-based canvas, rendering directly onto it, and saving it to an image:
var surfaceProvider = new GenericSkiaCanvasProvider<SKSurface>(
size =>
{
var surface = SKSurface.Create(new SKImageInfo((int)size.Width, (int)size.Height, SKColorType.Rgba8888, SKAlphaType.Unpremul));
return Tuple.Create(surface.Canvas, surface);
},
surface =>
{
using (var image = surface.Snapshot())
using (var data = image.Encode(SKEncodedImageFormat.Png, 100))
{
using (var stream = File.OpenWrite(Path.Combine(OutputFolder, "surface_output.png")))
{
data.SaveTo(stream);
}
}
surface.Dispose();
}
);
var options = new Aspose.Svg.Rendering.RenderingOptions { PageSetup = { Sizing = SizingType.FitContent } };
using (var document = new SVGDocument(Path.Combine(InputFolder, "test.svg")))
using (var device = new SkiaCanvasDevice(options, surfaceProvider))
{
document.RenderTo(device);
}
Source*
Add Vector-based Recording to C# Apps
Developers can seamlessly add vector-based recording to their .NET SVG processing apps and generate quality SVG rendering outputs. This C# code sample shows how to add this capability to your SVG apps using SKPictureRecorder
.
var recorderProvider = new GenericSkiaCanvasProvider<SKPictureRecorder>(
size =>
{
var recorder = new SKPictureRecorder();
var canvas = recorder.BeginRecording(new SKRect(0, 0, size.Width, size.Height));
return Tuple.Create(canvas, recorder);
},
recorder =>
{
using (var picture = recorder.EndRecording())
using (var image = SKImage.FromPicture(picture, new SKSizeI((int)picture.CullRect.Width, (int)picture.CullRect.Height)))
using (var data = image.Encode(SKEncodedImageFormat.Png, 100))
{
using (var stream = File.OpenWrite(Path.Combine(OutputFolder, "recorder_output.png")))
{
data.SaveTo(stream);
}
}
}
);
var options = new Aspose.Svg.Rendering.RenderingOptions { PageSetup = { Sizing = SizingType.FitContent } };
using (var document = new SVGDocument(Path.Combine(InputFolder, "test.svg")))
using (var device = new SkiaCanvasDevice(options, recorderProvider))
{
document.RenderTo(device);
}
Source*
Improved SVG Builder API
In version 24.4.0 of Aspose.SVG for .NET, the SVG Builder API has been optimized to process the font-size attribute accurately and ensure consistent rendering that aligns with SVG standards.
Enhanced SkiaSharp
Rendering
The SVG processing library now boasts improved SkiaSharp
-based SVG rendering, focusing on accurate font styles for italic and bold text.
You can view the list of all new features, enhancements, and bug fixes introduced in this release by visiting Aspose.SVG for .NET 24.4.0 Release Notes.