Browse Source

Improve error message for invalid surface size (#20591)

pull/20592/head
Julien Lebosquain 4 months ago
committed by GitHub
parent
commit
92190e6ee1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 8
      src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs

8
src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs

@ -125,6 +125,14 @@ namespace Avalonia.Skia
_currentFramebufferAddress = framebuffer.Address;
// A surface with a width/height of 0 is invalid and can't be created
if (desiredImageInfo.Width <= 0 || desiredImageInfo.Height <= 0)
{
throw new ArgumentException(
$"Unable to create a surface with size {desiredImageInfo.Width}x{desiredImageInfo.Height}",
nameof(desiredImageInfo));
}
var surface = SKSurface.Create(desiredImageInfo, _currentFramebufferAddress,
framebuffer.RowBytes, new SKSurfaceProperties(SKPixelGeometry.RgbHorizontal));

Loading…
Cancel
Save