From 39153debab248cd7704860ee0d59be7f6d182e47 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 14 Aug 2016 12:28:57 +1000 Subject: [PATCH] Cleanup bmp encoder Former-commit-id: e6ae6c39ce5d83da0762fde1a2bd2c6428dced97 Former-commit-id: f81b2f43de2696e18fe5399fbb456f0f9a9b0cda Former-commit-id: 849e263b02fbb25a317a732da50f94172af719ff --- .../Formats/Bmp/BmpEncoderCore.cs | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs b/src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs index 6c46f2d6b..95cb55d36 100644 --- a/src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs @@ -5,7 +5,6 @@ namespace ImageProcessorCore.Formats { - using System; using System.IO; using IO; @@ -21,7 +20,7 @@ namespace ImageProcessorCore.Formats private BmpBitsPerPixel bmpBitsPerPixel; /// - /// The amount to pad each row by. + /// The amount to pad each row by. /// private int padding; @@ -44,7 +43,7 @@ namespace ImageProcessorCore.Formats // Cast to int will get the bytes per pixel short bpp = (short)(8 * (int)bitsPerPixel); - int bytesPerLine = 4 * ((image.Width * bpp + 31) / 32); + int bytesPerLine = 4 * (((image.Width * bpp) + 31) / 32); this.padding = bytesPerLine - (image.Width * (int)bitsPerPixel); // Do not use IDisposable pattern here as we want to preserve the stream. @@ -121,9 +120,8 @@ namespace ImageProcessorCore.Formats /// Writes the pixel data to the binary stream. /// /// The pixel format. - /// The packed format. long, float./// - /// The containing the stream to write to. - /// + /// The packed format. long, float. + /// The containing the stream to write to. /// /// The containing pixel data. /// @@ -133,14 +131,14 @@ namespace ImageProcessorCore.Formats { using (IPixelAccessor pixels = image.Lock()) { - switch (bmpBitsPerPixel) + switch (this.bmpBitsPerPixel) { case BmpBitsPerPixel.Pixel32: - this.Write32bit(writer, pixels); + this.Write32Bit(writer, pixels); break; case BmpBitsPerPixel.Pixel24: - this.Write24bit(writer, pixels); + this.Write24Bit(writer, pixels); break; } } @@ -153,7 +151,7 @@ namespace ImageProcessorCore.Formats /// The packed format. long, float. /// The containing the stream to write to. /// The containing pixel data. - private void Write32bit(EndianBinaryWriter writer, IPixelAccessor pixels) + private void Write32Bit(EndianBinaryWriter writer, IPixelAccessor pixels) where T : IPackedVector where TP : struct { @@ -180,7 +178,7 @@ namespace ImageProcessorCore.Formats /// The pixel format. /// The packed format. long, float./// The containing the stream to write to. /// The containing pixel data. - private void Write24bit(EndianBinaryWriter writer, IPixelAccessor pixels) + private void Write24Bit(EndianBinaryWriter writer, IPixelAccessor pixels) where T : IPackedVector where TP : struct {