diff --git a/src/ImageProcessorCore/Formats/Bmp/BmpEncoder.cs b/src/ImageProcessorCore/Formats/Bmp/BmpEncoder.cs index 08f73b181..960869e9f 100644 --- a/src/ImageProcessorCore/Formats/Bmp/BmpEncoder.cs +++ b/src/ImageProcessorCore/Formats/Bmp/BmpEncoder.cs @@ -43,7 +43,7 @@ namespace ImageProcessorCore.Formats } /// - public void Encode(ImageBase image, Stream stream) + public void Encode(Image image, Stream stream) where T : IPackedVector where TP : struct { diff --git a/src/ImageProcessorCore/Formats/Gif/GifEncoder.cs b/src/ImageProcessorCore/Formats/Gif/GifEncoder.cs index 4ece1c769..af3475ea2 100644 --- a/src/ImageProcessorCore/Formats/Gif/GifEncoder.cs +++ b/src/ImageProcessorCore/Formats/Gif/GifEncoder.cs @@ -47,7 +47,7 @@ namespace ImageProcessorCore.Formats } /// - public void Encode(ImageBase image, Stream stream) + public void Encode(Image image, Stream stream) where T : IPackedVector where TP : struct { diff --git a/src/ImageProcessorCore/Formats/Gif/GifEncoderCore.cs b/src/ImageProcessorCore/Formats/Gif/GifEncoderCore.cs index 9ac7c2d58..35cb28e0e 100644 --- a/src/ImageProcessorCore/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageProcessorCore/Formats/Gif/GifEncoderCore.cs @@ -40,21 +40,19 @@ namespace ImageProcessorCore.Formats public IQuantizer Quantizer { get; set; } /// - /// Encodes the image to the specified stream from the . + /// Encodes the image to the specified stream from the . /// /// The pixel format. /// The packed format. long, float. - /// The to encode from. + /// The to encode from. /// The to encode the image data to. - public void Encode(ImageBase imageBase, Stream stream) + public void Encode(Image image, Stream stream) where T : IPackedVector where TP : struct { - Guard.NotNull(imageBase, nameof(imageBase)); + Guard.NotNull(image, nameof(image)); Guard.NotNull(stream, nameof(stream)); - Image image = (Image)imageBase; - if (this.Quantizer == null) { this.Quantizer = new OctreeQuantizer { Threshold = this.Threshold }; @@ -64,7 +62,7 @@ namespace ImageProcessorCore.Formats EndianBinaryWriter writer = new EndianBinaryWriter(EndianBitConverter.Little, stream); // Ensure that quality can be set but has a fallback. - int quality = this.Quality > 0 ? this.Quality : imageBase.Quality; + int quality = this.Quality > 0 ? this.Quality : image.Quality; this.Quality = quality > 0 ? quality.Clamp(1, 256) : 256; // Get the number of bits. @@ -80,7 +78,7 @@ namespace ImageProcessorCore.Formats this.WriteLogicalScreenDescriptor(image, writer, quantized.TransparentIndex); // Write the first frame. - this.WriteGraphicalControlExtension(imageBase, writer, quantized.TransparentIndex); + this.WriteGraphicalControlExtension(image, writer, quantized.TransparentIndex); this.WriteImageDescriptor(image, writer); this.WriteColorTable(quantized, writer); this.WriteImageData(quantized, writer); diff --git a/src/ImageProcessorCore/Formats/IImageEncoder.cs b/src/ImageProcessorCore/Formats/IImageEncoder.cs index 2cdd78792..09b2fca7d 100644 --- a/src/ImageProcessorCore/Formats/IImageEncoder.cs +++ b/src/ImageProcessorCore/Formats/IImageEncoder.cs @@ -38,13 +38,13 @@ namespace ImageProcessorCore.Formats bool IsSupportedFileExtension(string extension); /// - /// Encodes the image to the specified stream from the . + /// Encodes the image to the specified stream from the . /// /// The pixel format. /// The packed format. long, float. - /// The to encode from. + /// The to encode from. /// The to encode the image data to. - void Encode(ImageBase image, Stream stream) + void Encode(Image image, Stream stream) where T : IPackedVector where TP : struct; } diff --git a/src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id b/src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id index 548cdf74c..d5d55bcd2 100644 --- a/src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id +++ b/src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id @@ -1 +1 @@ -adc0f0265d9f43bfcc4b6e12b48eda9c8f48b81a \ No newline at end of file +25b2ab2a0acfb874ca8ac8ae979fc6b1bc9bf466 \ No newline at end of file diff --git a/src/ImageProcessorCore/Formats/Jpg/JpegEncoder.cs b/src/ImageProcessorCore/Formats/Jpg/JpegEncoder.cs index 9a267f79b..72b7eace1 100644 --- a/src/ImageProcessorCore/Formats/Jpg/JpegEncoder.cs +++ b/src/ImageProcessorCore/Formats/Jpg/JpegEncoder.cs @@ -78,7 +78,7 @@ namespace ImageProcessorCore.Formats } /// - public void Encode(ImageBase image, Stream stream) + public void Encode(Image image, Stream stream) where T : IPackedVector where TP : struct { diff --git a/src/ImageProcessorCore/Formats/Jpg/JpegEncoderCore.cs b/src/ImageProcessorCore/Formats/Jpg/JpegEncoderCore.cs index 041fcf940..48c65caad 100644 --- a/src/ImageProcessorCore/Formats/Jpg/JpegEncoderCore.cs +++ b/src/ImageProcessorCore/Formats/Jpg/JpegEncoderCore.cs @@ -430,7 +430,7 @@ namespace ImageProcessorCore.Formats // Encode writes the Image m to w in JPEG 4:2:0 baseline format with the given // options. Default parameters are used if a nil *Options is passed. - public void Encode(ImageBase image, Stream stream, int quality, JpegSubsample sample) + public void Encode(Image image, Stream stream, int quality, JpegSubsample sample) where T : IPackedVector where TP : struct { @@ -488,8 +488,8 @@ namespace ImageProcessorCore.Formats int componentCount = 3; // Write the Start Of Image marker. - double densityX = ((Image)image).HorizontalResolution; - double densityY = ((Image)image).VerticalResolution; + double densityX = image.HorizontalResolution; + double densityY = image.VerticalResolution; WriteApplicationHeader((short)densityX, (short)densityY); diff --git a/src/ImageProcessorCore/Formats/Png/PngEncoder.cs b/src/ImageProcessorCore/Formats/Png/PngEncoder.cs index 43b7aa554..3aaaf19a7 100644 --- a/src/ImageProcessorCore/Formats/Png/PngEncoder.cs +++ b/src/ImageProcessorCore/Formats/Png/PngEncoder.cs @@ -67,7 +67,7 @@ namespace ImageProcessorCore.Formats } /// - public void Encode(ImageBase image, Stream stream) + public void Encode(Image image, Stream stream) where T : IPackedVector where TP : struct { diff --git a/src/ImageProcessorCore/Image/ImageExtensions.cs b/src/ImageProcessorCore/Image/ImageExtensions.cs index 0b1bac55e..b9ff38a7c 100644 --- a/src/ImageProcessorCore/Image/ImageExtensions.cs +++ b/src/ImageProcessorCore/Image/ImageExtensions.cs @@ -24,7 +24,7 @@ namespace ImageProcessorCore /// The image this method extends. /// The stream to save the image to. /// Thrown if the stream is null. - public static void SaveAsBmp(this ImageBase source, Stream stream) + public static void SaveAsBmp(this Image source, Stream stream) where T : IPackedVector where TP : struct => new BmpEncoder().Encode(source, stream); @@ -41,7 +41,7 @@ namespace ImageProcessorCore /// Anything equal to 256 and below will cause the encoder to save the image in an indexed format. /// /// Thrown if the stream is null. - public static void SaveAsPng(this ImageBase source, Stream stream, int quality = int.MaxValue) + public static void SaveAsPng(this Image source, Stream stream, int quality = int.MaxValue) where T : IPackedVector where TP : struct => new PngEncoder { Quality = quality }.Encode(source, stream); @@ -55,7 +55,7 @@ namespace ImageProcessorCore /// The stream to save the image to. /// The quality to save the image to. Between 1 and 100. /// Thrown if the stream is null. - public static void SaveAsJpeg(this ImageBase source, Stream stream, int quality = 75) + public static void SaveAsJpeg(this Image source, Stream stream, int quality = 75) where T : IPackedVector where TP : struct => new JpegEncoder { Quality = quality }.Encode(source, stream); @@ -69,7 +69,7 @@ namespace ImageProcessorCore /// The stream to save the image to. /// The quality to save the image to representing the number of colors. Between 1 and 256. /// Thrown if the stream is null. - internal static void SaveAsGif(this ImageBase source, Stream stream, int quality = 256) + internal static void SaveAsGif(this Image source, Stream stream, int quality = 256) where T : IPackedVector where TP : struct => new GifEncoder { Quality = quality }.Encode(source, stream);