Skip to content

Commit 97b72ba

Browse files
authored
Bitmap / Remove exception in SetResolution method (#22)
* Avoid raising exception on Bitmap's SetResolution method
1 parent 04062bb commit 97b72ba

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Common/Bitmap.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,14 @@ public void SetResolution(float xDpi, float yDpi)
275275
{
276276
if (xDpi <= 0 || yDpi <= 0)
277277
throw new ArgumentOutOfRangeException("DPI values must be greater than zero.");
278-
throw new NotSupportedException("not supported by skia"); // SOURCE: https://issues.skia.org/issues/40043604
278+
if (float.IsNaN(xDpi) || float.IsInfinity(xDpi))
279+
throw new ArgumentException($"DPI values must be numbers but {xDpi} was given.", nameof(xDpi));
280+
if (float.IsNaN(yDpi) || float.IsInfinity(yDpi))
281+
throw new ArgumentException($"DPI values must be numbers but {yDpi} was given.", nameof(yDpi));
282+
HorizontalResolution = xDpi;
283+
VerticalResolution = yDpi;
284+
// NOTE: HorizontalResolution and VerticalResolution properties assignment has no effect
285+
// on Save because Skia does not support it (source: https://issues.skia.org/issues/40043604)
279286
}
280287

281288
/// <summary>

0 commit comments

Comments
 (0)