Skip to content

Commit

Permalink
Enforce braces in if-statements
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Nov 4, 2024
1 parent 4b61ada commit 5b31a8f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/NetVips.Extensions/BitmapConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ private static Enums.BandFormat GuessBandFormat(PixelFormat pixelFormat)
public static Image ToVips(this Bitmap src)
{
if (src == null)
{
throw new ArgumentNullException(nameof(src));
}

// Let LockBits convert the pixel data to Format24bppRgb for indexed
// (excluding Format8bppIndexed) and Format32bppRgb (the remaining
Expand Down Expand Up @@ -200,7 +202,9 @@ src.PixelFormat is PixelFormat.Format1bppIndexed or PixelFormat.Format4bppIndexe
finally
{
if (bd != null)
{
src.UnlockBits(bd);
}
}

if (pf == PixelFormat.Format8bppIndexed)
Expand Down Expand Up @@ -267,7 +271,9 @@ public static Image ToVips(this System.Drawing.Image src)
public static Bitmap ToBitmap(this Image src)
{
if (src == null)
{
throw new ArgumentNullException(nameof(src));
}

// Ensure image is converted to sRGB
if (src.Bands >= 3)
Expand Down Expand Up @@ -414,9 +420,14 @@ public static Bitmap ToBitmap(this Image src)
finally
{
if (bd != null)
{
dst.UnlockBits(bd);
}

if (memory != IntPtr.Zero)
{
NetVips.Free(memory);
}
}

return dst;
Expand Down
5 changes: 4 additions & 1 deletion src/NetVips/ModuleInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ public static void Initialize()
Version = (Version << 8) + NetVips.Version(2, false);

#if NET6_0_OR_GREATER
if (!OperatingSystem.IsWindows()) return;
if (!OperatingSystem.IsWindows())
{
return;
}

try
{
Expand Down
2 changes: 2 additions & 0 deletions tests/NetVips.Tests/ExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public void ToBitmap4Bands()
private static void AssertPixelValue(byte[] expected, Bitmap actual)
{
if (actual.Width != 1 || actual.Height != 1)
{
throw new Exception("1x1 image only");
}

// An additional band is added for greyscale images
if (expected.Length == 2)
Expand Down

0 comments on commit 5b31a8f

Please sign in to comment.