Skip to content

Commit d523460

Browse files
authored
Merge pull request #47 from dlemstra/using-magick
Added using for GetPixels because the IPixelCollection is IDisposable.
2 parents 1d8a416 + 822d707 commit d523460

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Source/Bindings/ZXing.Magick/MagickImageLuminanceSource.cs

+10-8
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,18 @@ protected override LuminanceSource CreateLuminanceSource(byte[] newLuminances, i
6262
private void CalculateLuminance(MagickImage src)
6363
{
6464
if (src == null)
65-
throw new ArgumentNullException("src");
65+
throw new ArgumentNullException(nameof(src));
6666

67-
var pixels = src.GetPixels();
68-
if (src.HasAlpha)
67+
using (var pixels = src.GetPixels())
6968
{
70-
CalculateLuminanceBGRA32(pixels, src.Width, src.Height);
71-
}
72-
else
73-
{
74-
CalculateLuminanceBGR24(pixels, src.Width, src.Height);
69+
if (src.HasAlpha)
70+
{
71+
CalculateLuminanceBGRA32(pixels, src.Width, src.Height);
72+
}
73+
else
74+
{
75+
CalculateLuminanceBGR24(pixels, src.Width, src.Height);
76+
}
7577
}
7678
}
7779

0 commit comments

Comments
 (0)