diff --git a/src/ImageSharp.Formats.Bmp/BmpEncoderCore.cs b/src/ImageSharp.Formats.Bmp/BmpEncoderCore.cs index 94f2b3a38..8abe7cbfc 100644 --- a/src/ImageSharp.Formats.Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp.Formats.Bmp/BmpEncoderCore.cs @@ -34,7 +34,7 @@ namespace ImageSharp.Formats /// The public void Encode(ImageBase image, Stream stream, BmpBitsPerPixel bitsPerPixel) where TColor : struct, IPackedPixel, IEquatable - { + { Guard.NotNull(image, nameof(image)); Guard.NotNull(stream, nameof(stream)); @@ -119,23 +119,23 @@ namespace ImageSharp.Formats /// Writes the pixel data to the binary stream. /// /// The pixel format. - /// The containing the stream to write to. + /// The containing the stream to write to. /// /// The containing pixel data. /// private void WriteImage(EndianBinaryWriter writer, ImageBase image) where TColor : struct, IPackedPixel, IEquatable - { + { using (PixelAccessor pixels = image.Lock()) { 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; } } @@ -145,11 +145,11 @@ namespace ImageSharp.Formats /// Writes the 32bit color palette to the stream. /// /// The pixel format. - /// The containing the stream to write to. + /// The containing the stream to write to. /// The containing pixel data. private void Write32Bit(EndianBinaryWriter writer, PixelAccessor pixels) where TColor : struct, IPackedPixel, IEquatable - { + { using (PixelArea row = new PixelArea(pixels.Width, ComponentOrder.Zyxw, this.padding)) { for (int y = pixels.Height - 1; y >= 0; y--) @@ -164,11 +164,11 @@ namespace ImageSharp.Formats /// Writes the 24bit color palette to the stream. /// /// The pixel format. - /// The containing the stream to write to. + /// The containing the stream to write to. /// The containing pixel data. private void Write24Bit(EndianBinaryWriter writer, PixelAccessor pixels) where TColor : struct, IPackedPixel, IEquatable - { + { using (PixelArea row = new PixelArea(pixels.Width, ComponentOrder.Zyx, this.padding)) { for (int y = pixels.Height - 1; y >= 0; y--) diff --git a/src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs b/src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs index 72655a500..1fd963292 100644 --- a/src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs @@ -5,10 +5,8 @@ namespace ImageSharp.Formats { using System; - using System.Buffers; using System.IO; using System.Runtime.CompilerServices; - using System.Runtime.InteropServices; using System.Threading.Tasks; using ImageSharp.Formats.Jpg; @@ -586,7 +584,7 @@ namespace ImageSharp.Formats byte yellow = this.ycbcrImage.CrChannel.Pixels[co + (x / scale)]; TColor packed = default(TColor); - this.PackCmyk(ref packed, cyan, magenta, yellow, x, y); + this.PackCmyk(ref packed, cyan, magenta, yellow, x, y); pixels[x, y] = packed; } }); @@ -744,7 +742,7 @@ namespace ImageSharp.Formats byte cr = this.ycbcrImage.CrChannel.Pixels[co + (x / scale)]; TColor packed = default(TColor); - this.PackYcck(ref packed, yy, cb, cr, x, y); + this.PackYcck(ref packed, yy, cb, cr, x, y); pixels[x, y] = packed; } }); @@ -1037,7 +1035,7 @@ namespace ImageSharp.Formats } this.InputProcessor.ReadFull(this.Temp, 0, remaining); - this.RestartInterval = ((int)this.Temp[0] << 8) + (int)this.Temp[1]; + this.RestartInterval = (this.Temp[0] << 8) + this.Temp[1]; } /// diff --git a/src/ImageSharp.Formats.Jpeg/JpegEncoderCore.cs b/src/ImageSharp.Formats.Jpeg/JpegEncoderCore.cs index a97bc4bca..984418dd3 100644 --- a/src/ImageSharp.Formats.Jpeg/JpegEncoderCore.cs +++ b/src/ImageSharp.Formats.Jpeg/JpegEncoderCore.cs @@ -8,7 +8,6 @@ namespace ImageSharp.Formats using System; using System.Buffers; using System.IO; - using System.Numerics; using System.Runtime.CompilerServices; using ImageSharp.Formats.Jpg; diff --git a/src/ImageSharp/Image/ImageBase{TColor}.cs b/src/ImageSharp/Image/ImageBase{TColor}.cs index e6c14f0e9..1b3abd360 100644 --- a/src/ImageSharp/Image/ImageBase{TColor}.cs +++ b/src/ImageSharp/Image/ImageBase{TColor}.cs @@ -6,7 +6,6 @@ namespace ImageSharp { using System; - using System.Buffers; using System.Diagnostics; ///