The DLLs-only package of Aspose.SVG for .NET 24.4.0 allows developers to integrate enhanced SVG rendering capabilities into their SVG processing with SkiaSharp
on any platform.
Render to SKCanvas Directly
Add direct rendering to SKCanvas
within the C# apps using this release of the .NET SVG library. It facilitates a more efficient and integrated workflow with SkiaSharp
. This enhancement offers 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*
Vector-based Recording for Your Apps
You can effortlessly add vector-based recording to your .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*
Upgraded SVG Builder API
Version 24.4.0 of Aspose.SVG for .NET delivers an updated SVG Builder API to process the font-size attribute accurately and ensure consistent rendering that aligns with SVG standards.
Improved SkiaSharp
Rendering
The SVG processing library now includes enhanced 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.