Skip to content

Commit

Permalink
Merge pull request #47 from dlemstra/using-magick
Browse files Browse the repository at this point in the history
Added using for GetPixels because the IPixelCollection is IDisposable.
  • Loading branch information
micjahn committed Oct 9, 2017
2 parents 1d8a416 + 822d707 commit d523460
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 d523460

Please sign in to comment.