Skip to content

Commit

Permalink
Added using for GetPixels because the IPixelCollection is IDisposable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirk Lemstra committed Oct 8, 2017
1 parent 1d8a416 commit 822d707
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Source/Bindings/ZXing.Magick/MagickImageLuminanceSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,18 @@ protected override LuminanceSource CreateLuminanceSource(byte[] newLuminances, i
private void CalculateLuminance(MagickImage src)
{
if (src == null)
throw new ArgumentNullException("src");
throw new ArgumentNullException(nameof(src));

var pixels = src.GetPixels();
if (src.HasAlpha)
using (var pixels = src.GetPixels())
{
CalculateLuminanceBGRA32(pixels, src.Width, src.Height);
}
else
{
CalculateLuminanceBGR24(pixels, src.Width, src.Height);
if (src.HasAlpha)
{
CalculateLuminanceBGRA32(pixels, src.Width, src.Height);
}
else
{
CalculateLuminanceBGR24(pixels, src.Width, src.Height);
}
}
}

Expand Down

0 comments on commit 822d707

Please sign in to comment.