Improve error message for invalid surface size (#20591)

This commit is contained in:
Julien Lebosquain
2026-02-02 21:57:27 +00:00
committed by GitHub
parent 7d9c8eeb7b
commit 92190e6ee1
@@ -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));