Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/SingleProject/Resizetizer/src/SkiaSharpSvgTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,18 @@ public override SKSize GetOriginalSize() =>

public override void DrawUnscaled(SKCanvas canvas, float scale)
{
var size = GetOriginalSize();
if (size.IsEmpty)
{
throw new InvalidOperationException($"Cannot draw SVG file '{Filename}'. The SVG has no size. Ensure the SVG includes a viewBox attribute or both width and height attributes with valid dimensions.");
}
if (scale >= 1)
{
// draw using default scaling
canvas.DrawPicture(svg.Picture, Paint);
}
else
{
// draw using raster downscaling
var size = GetOriginalSize();

// vector scaling has rounding issues, so first draw as intended
var info = new SKImageInfo((int)size.Width, (int)size.Height);
using var surface = SKSurface.Create(info);
Expand Down
Loading