Browse Source

Revert Unsafe.Copy and cleanup

Former-commit-id: 401fa40681eb231eabcfe11f5115c05404c84498
Former-commit-id: 160012def06309092c8ee00cba8fa99a53f83ebf
Former-commit-id: bf644e6660e40cb25e20de9058bc181284730409
pull/1/head
James Jackson-South 10 years ago
parent
commit
ccc13bbac3
  1. 5
      src/ImageProcessorCore/Bootstrapper.cs
  2. 7
      src/ImageProcessorCore/Colors/Colorspaces/IAlmostEquatable.cs
  3. 2
      src/ImageProcessorCore/Common/Extensions/ByteExtensions.cs
  4. 77
      src/ImageProcessorCore/Common/Helpers/Guard.cs
  5. 6
      src/ImageProcessorCore/Filters/Blend.cs
  6. 8
      src/ImageProcessorCore/Filters/BoxBlur.cs
  7. 4
      src/ImageProcessorCore/Filters/DetectEdges.cs
  8. 8
      src/ImageProcessorCore/Filters/Invert.cs
  9. 2
      src/ImageProcessorCore/Filters/Kodachrome.cs
  10. 6
      src/ImageProcessorCore/Filters/Pixelate.cs
  11. 2
      src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs
  12. 2
      src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs
  13. 4
      src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs
  14. 2
      src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs
  15. 2
      src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs
  16. 13
      src/ImageProcessorCore/Filters/Processors/ColorMatrix/HueProcessor.cs
  17. 2
      src/ImageProcessorCore/Filters/Processors/ColorMatrix/IColorMatrixFilter.cs
  18. 2
      src/ImageProcessorCore/Filters/Processors/ColorMatrix/PolaroidProcessor.cs
  19. 24
      src/ImageProcessorCore/Filters/Processors/ColorMatrix/SaturationProcessor.cs
  20. 2
      src/ImageProcessorCore/Filters/Processors/ColorMatrix/SepiaProcessor.cs
  21. 8
      src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs
  22. 2
      src/ImageProcessorCore/Filters/Processors/Convolution/BoxBlurProcessor.cs
  23. 2
      src/ImageProcessorCore/Filters/Processors/Convolution/ConvolutionFilter.cs
  24. 2
      src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/EdgeDetector2DFilter.cs
  25. 2
      src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/EdgeDetectorFilter.cs
  26. 2
      src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/IEdgeDetectorFilter.cs
  27. 6
      src/ImageProcessorCore/Filters/Processors/Convolution/GuassianBlurProcessor.cs
  28. 6
      src/ImageProcessorCore/Filters/Processors/Convolution/GuassianSharpenProcessor.cs
  29. 6
      src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs
  30. 4
      src/ImageProcessorCore/Filters/Processors/PixelateProcessor.cs
  31. 3
      src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs
  32. 2
      src/ImageProcessorCore/Filters/Sepia.cs
  33. 4
      src/ImageProcessorCore/Formats/Bmp/BmpDecoder.cs
  34. 11
      src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs
  35. 15
      src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs
  36. 2
      src/ImageProcessorCore/Formats/Gif/GifDecoderCore.cs
  37. 1
      src/ImageProcessorCore/Formats/Gif/LzwDecoder.cs
  38. 2
      src/ImageProcessorCore/Formats/Gif/LzwEncoder.cs
  39. 2
      src/ImageProcessorCore/Formats/Gif/Sections/GifGraphicsControlExtension.cs
  40. 4
      src/ImageProcessorCore/Formats/IImageEncoder.cs
  41. 2
      src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id
  42. 10
      src/ImageProcessorCore/Formats/Jpg/JpegEncoderCore.cs
  43. 2
      src/ImageProcessorCore/Formats/Png/Filters/UpFilter.cs
  44. 2
      src/ImageProcessorCore/Formats/Png/PngDecoder.cs
  45. 13
      src/ImageProcessorCore/Formats/Png/PngDecoderCore.cs
  46. 4
      src/ImageProcessorCore/Formats/Png/PngEncoder.cs
  47. 2
      src/ImageProcessorCore/IO/EndianBitConverter.cs
  48. 12
      src/ImageProcessorCore/Image/IImageBase.cs
  49. 4
      src/ImageProcessorCore/Image/IImageProcessor.cs
  50. 53
      src/ImageProcessorCore/Image/ImageBase.cs
  51. 20
      src/ImageProcessorCore/Image/ImageExtensions.cs
  52. 3
      src/ImageProcessorCore/Image/PixelAccessor.cs
  53. 4
      src/ImageProcessorCore/ImageProcessor.cs
  54. 2
      src/ImageProcessorCore/Profiles/Exif/ExifProfile.cs
  55. 2
      src/ImageProcessorCore/Quantizers/IQuantizer.cs
  56. 32
      src/ImageProcessorCore/Quantizers/Octree/OctreeQuantizer.cs
  57. 6
      src/ImageProcessorCore/Quantizers/Octree/Quantizer.cs
  58. 4
      src/ImageProcessorCore/Quantizers/Quantize.cs
  59. 4
      src/ImageProcessorCore/Quantizers/QuantizedImage.cs
  60. 2
      src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs
  61. 31
      src/ImageProcessorCore/Samplers/AutoOrient.cs
  62. 18
      src/ImageProcessorCore/Samplers/Options/ResizeHelper.cs
  63. 4
      src/ImageProcessorCore/Samplers/Processors/EntropyCropProcessor.cs
  64. 2
      src/ImageProcessorCore/Samplers/Processors/ImageSampler.cs
  65. 16
      src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs
  66. 2
      src/ImageProcessorCore/Samplers/Resamplers/NearestNeighborResampler.cs
  67. 4
      src/ImageProcessorCore/Samplers/RotateFlip.cs

5
src/ImageProcessorCore/Bootstrapper.cs

@ -8,7 +8,6 @@ namespace ImageProcessorCore
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;
using System.Threading.Tasks;
using Formats;
@ -51,8 +50,8 @@ namespace ImageProcessorCore
/// <summary>
/// Gets the collection of supported <see cref="IImageFormat"/>
/// </summary>
public IReadOnlyCollection<IImageFormat> ImageFormats =>
new ReadOnlyCollection<IImageFormat>(this.imageFormats);
public IReadOnlyCollection<IImageFormat> ImageFormats => new ReadOnlyCollection<IImageFormat>(this.imageFormats);
/// <summary>
/// Gets or sets the global parallel options for processing tasks in parallel.

7
src/ImageProcessorCore/Colors/Colorspaces/IAlmostEquatable.cs

@ -12,8 +12,9 @@ namespace ImageProcessorCore
/// a type-specific method for determining approximate equality of instances.
/// </summary>
/// <typeparam name="TColor">The type of objects to compare.</typeparam>
/// <typeparam name="TPacked">The object specifying the type to specify precision with.</typeparam>
public interface IAlmostEquatable<TColor, TPacked> where TPacked : struct, IComparable<TPacked>
/// <typeparam name="TPrecision">The object specifying the type to specify precision with.</typeparam>
public interface IAlmostEquatable<in TColor, in TPrecision>
where TPrecision : struct, IComparable<TPrecision>
{
/// <summary>
/// Indicates whether the current object is equal to another object of the same type
@ -24,6 +25,6 @@ namespace ImageProcessorCore
/// <returns>
/// true if the current object is equal to the other parameter; otherwise, false.
/// </returns>
bool AlmostEquals(TColor other, TPacked precision);
bool AlmostEquals(TColor other, TPrecision precision);
}
}

2
src/ImageProcessorCore/Common/Extensions/ByteExtensions.cs

@ -20,7 +20,7 @@ namespace ImageProcessorCore
/// <param name="bits">The number of bits per value.</param>
/// <returns>The resulting <see cref="T:byte[]"/> array. Is never null.</returns>
/// <exception cref="System.ArgumentNullException"><paramref name="bytes"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="bits"/> is less than or equals than zero.</exception>
/// <exception cref="System.ArgumentException"><paramref name="bits"/> is less than or equals than zero.</exception>
public static byte[] ToArrayByBitsLength(this byte[] bytes, int bits)
{
Guard.NotNull(bytes, "bytes");

77
src/ImageProcessorCore/Common/Helpers/Guard.cs

@ -1,16 +1,8 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Guard.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// <copyright file="Guard.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Provides methods to protect against invalid parameters.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("ImageProcessorCore.Tests")]
namespace ImageProcessorCore
{
using System;
@ -26,18 +18,10 @@ namespace ImageProcessorCore
/// Verifies, that the method parameter with specified object value is not null
/// and throws an exception if it is found to be so.
/// </summary>
/// <param name="target">
/// The target object, which cannot be null.
/// </param>
/// <param name="parameterName">
/// The name of the parameter that is to be checked.
/// </param>
/// <param name="message">
/// The error message, if any to add to the exception.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="target"/> is null
/// </exception>
/// <param name="target">The target object, which cannot be null.</param>
/// <param name="parameterName">The name of the parameter that is to be checked.</param>
/// <param name="message">The error message, if any to add to the exception.</param>
/// <exception cref="ArgumentNullException"><paramref name="target"/> is null</exception>
public static void NotNull(object target, string parameterName, string message = "")
{
if (target == null)
@ -58,13 +42,8 @@ namespace ImageProcessorCore
/// </summary>
/// <param name="target">The target string, which should be checked against being null or empty.</param>
/// <param name="parameterName">Name of the parameter.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="target"/> is null.
/// </exception>
/// <exception cref="ArgumentException">
/// <paramref name="target"/> is
/// empty or contains only blanks.
/// </exception>
/// <exception cref="ArgumentNullException"><paramref name="target"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="target"/> is empty or contains only blanks.</exception>
public static void NotNullOrEmpty(string target, string parameterName)
{
if (target == null)
@ -94,9 +73,7 @@ namespace ImageProcessorCore
{
if (value.CompareTo(max) >= 0)
{
throw new ArgumentOutOfRangeException(
parameterName,
$"Value must be less than {max}.");
throw new ArgumentOutOfRangeException(parameterName, $"Value must be less than {max}.");
}
}
@ -116,9 +93,7 @@ namespace ImageProcessorCore
{
if (value.CompareTo(max) > 0)
{
throw new ArgumentOutOfRangeException(
parameterName,
$"Value must be less than or equal to {max}.");
throw new ArgumentOutOfRangeException(parameterName, $"Value must be less than or equal to {max}.");
}
}
@ -134,7 +109,7 @@ namespace ImageProcessorCore
/// <paramref name="value"/> is less than the minimum value.
/// </exception>
public static void MustBeGreaterThan<TValue>(TValue value, TValue min, string parameterName)
where TValue : IComparable<TValue>
where TValue : IComparable<TValue>
{
if (value.CompareTo(min) <= 0)
{
@ -156,13 +131,11 @@ namespace ImageProcessorCore
/// <paramref name="value"/> is less than the minimum value.
/// </exception>
public static void MustBeGreaterThanOrEqualTo<TValue>(TValue value, TValue min, string parameterName)
where TValue : IComparable<TValue>
where TValue : IComparable<TValue>
{
if (value.CompareTo(min) < 0)
{
throw new ArgumentOutOfRangeException(
parameterName,
$"Value must be greater than or equal to {min}.");
throw new ArgumentOutOfRangeException(parameterName, $"Value must be greater than or equal to {min}.");
}
}
@ -175,17 +148,15 @@ namespace ImageProcessorCore
/// <param name="max">The maximum value.</param>
/// <param name="parameterName">The name of the parameter that is to be checked.</param>
/// <typeparam name="TValue">The type of the value.</typeparam>
/// <exception cref="ArgumentException">
/// <exception cref="System.ArgumentException">
/// <paramref name="value"/> is less than the minimum value of greater than the maximum value.
/// </exception>
public static void MustBeBetweenOrEqualTo<TValue>(TValue value, TValue min, TValue max, string parameterName)
where TValue : IComparable<TValue>
where TValue : IComparable<TValue>
{
if (value.CompareTo(min) < 0 || value.CompareTo(max) > 0)
{
throw new ArgumentOutOfRangeException(
parameterName,
$"Value must be greater than or equal to {min} and less than or equal to {max}.");
throw new ArgumentOutOfRangeException(parameterName, $"Value must be greater than or equal to {min} and less than or equal to {max}.");
}
}
@ -202,7 +173,7 @@ namespace ImageProcessorCore
/// <param name="message">
/// The error message, if any to add to the exception.
/// </param>
/// <exception cref="ArgumentException">
/// <exception cref="System.ArgumentException">
/// <paramref name="target"/> is null
/// </exception>
public static void IsTrue(bool target, string parameterName, string message = "")
@ -222,15 +193,9 @@ namespace ImageProcessorCore
/// Verifies, that the method parameter with specified target value is false
/// and throws an exception if it is found to be so.
/// </summary>
/// <param name="target">
/// The target value, which cannot be true.
/// </param>
/// <param name="parameterName">
/// The name of the parameter that is to be checked.
/// </param>
/// <param name="message">
/// The error message, if any to add to the exception.
/// </param>
/// <param name="target">The target value, which cannot be true.</param>
/// <param name="parameterName">The name of the parameter that is to be checked.</param>
/// <param name="message">The error message, if any to add to the exception.</param>
/// <exception cref="ArgumentException">
/// <paramref name="target"/> is null
/// </exception>

6
src/ImageProcessorCore/Filters/Blend.cs

@ -1,7 +1,7 @@
// <copyright file="Blend.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>-------------------------------------------------------------------------------------------------------------------
// </copyright>
namespace ImageProcessorCore
{
@ -15,10 +15,10 @@ namespace ImageProcessorCore
/// <summary>
/// Combines the given image together with the current one by blending their pixels.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="image">The image to blend with the currently processing image.</param>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="image">The image to blend with the currently processing image.</param>
/// <param name="percent">The opacity of the image image to blend. Must be between 0 and 100.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>

8
src/ImageProcessorCore/Filters/BoxBlur.cs

@ -15,8 +15,8 @@ namespace ImageProcessorCore
/// <summary>
/// Applies a box blur to the image.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="radius">The 'radius' value representing the size of the area to sample.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
@ -31,8 +31,8 @@ namespace ImageProcessorCore
/// <summary>
/// Applies a box blur to the image.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="radius">The 'radius' value representing the size of the area to sample.</param>
/// <param name="rectangle">

4
src/ImageProcessorCore/Filters/DetectEdges.cs

@ -29,7 +29,7 @@ namespace ImageProcessorCore
}
/// <summary>
/// Detects any edges within the image. Uses the <see cref="SobelProcessor{TColor, TPacked}"/> filter
/// Detects any edges within the image. Uses the <see cref="SobelProcessor{T,TP}"/> filter
/// operating in Grayscale mode.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
@ -118,7 +118,7 @@ namespace ImageProcessorCore
break;
default:
processor = new ScharrProcessor<TColor, TPacked> { Grayscale = grayscale };
processor = new SobelProcessor<TColor, TPacked> { Grayscale = grayscale };
break;
}

8
src/ImageProcessorCore/Filters/Invert.cs

@ -1,20 +1,22 @@
// <copyright file="Invert.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>-------------------------------------------------------------------------------------------------------------------
// </copyright>
namespace ImageProcessorCore
{
using Processors;
/// <summary>
/// Extension methods for the <see cref="Image"/> type.
/// Extension methods for the <see cref="Image{TColor, TPacked}"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Inverts the colors of the image.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/>.</returns>
@ -28,6 +30,8 @@ namespace ImageProcessorCore
/// <summary>
/// Inverts the colors of the image.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.

2
src/ImageProcessorCore/Filters/Kodachrome.cs

@ -10,6 +10,8 @@ namespace ImageProcessorCore
/// <summary>
/// Extension methods for the <see cref="Image{TColor, TPacked}"/> type.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public static partial class ImageExtensions
{
/// <summary>

6
src/ImageProcessorCore/Filters/Pixelate.cs

@ -11,13 +11,13 @@ namespace ImageProcessorCore
/// <summary>
/// Extension methods for the <see cref="Image{TColor, TPacked}"/> type.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public static partial class ImageExtensions
{
/// <summary>
/// Pixelates and image with the given pixel size.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="size">The size of the pixels.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
@ -32,6 +32,8 @@ namespace ImageProcessorCore
/// <summary>
/// Pixelates and image with the given pixel size.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="size">The size of the pixels.</param>
/// <param name="rectangle">

2
src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs

@ -22,7 +22,7 @@ namespace ImageProcessorCore.Processors
/// Initializes a new instance of the <see cref="AlphaProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="percent">The percentage to adjust the opacity of the image. Must be between 0 and 100.</param>
/// <exception cref="ArgumentException">
/// <exception cref="System.ArgumentException">
/// <paramref name="percent"/> is less than 0 or is greater than 100.
/// </exception>
public AlphaProcessor(int percent)

2
src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs

@ -24,7 +24,7 @@ namespace ImageProcessorCore.Processors
/// <summary>
/// Initializes a new instance of the <see cref="BackgroundColorProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="color">The <see cref="T"/> to set the background color to.</param>
/// <param name="color">The <see cref="TColor"/> to set the background color to.</param>
public BackgroundColorProcessor(TColor color)
{
this.Value = color;

4
src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs

@ -22,7 +22,7 @@ namespace ImageProcessorCore.Processors
/// Initializes a new instance of the <see cref="BinaryThresholdProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="threshold">The threshold to split the image. Must be between 0 and 1.</param>
/// <exception cref="ArgumentException">
/// <exception cref="System.ArgumentException">
/// <paramref name="threshold"/> is less than 0 or is greater than 1.
/// </exception>
public BinaryThresholdProcessor(float threshold)
@ -111,4 +111,4 @@ namespace ImageProcessorCore.Processors
}
}
}
}
}

2
src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs

@ -24,7 +24,7 @@ namespace ImageProcessorCore.Processors
private readonly ImageBase<TColor, TPacked> blend;
/// <summary>
/// Initializes a new instance of the <see cref="BlendProcessor{TColor, TPacked}"/> class.
/// Initializes a new instance of the <see cref="BlendProcessor{T,TP}"/> class.
/// </summary>
/// <param name="image">
/// The image to blend with the currently processing image.

2
src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs

@ -22,7 +22,7 @@ namespace ImageProcessorCore.Processors
/// Initializes a new instance of the <see cref="BrightnessProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="brightness">The new brightness of the image. Must be between -100 and 100.</param>
/// <exception cref="ArgumentException">
/// <exception cref="System.ArgumentException">
/// <paramref name="brightness"/> is less than -100 or is greater than 100.
/// </exception>
public BrightnessProcessor(int brightness)

13
src/ImageProcessorCore/Filters/Processors/ColorMatrix/HueProcessor.cs

@ -9,7 +9,7 @@ namespace ImageProcessorCore.Processors
using System.Numerics;
/// <summary>
/// An <see cref="IImageProcessor{TColor, TPacked}"/> to change the hue of an <see cref="Image"/>.
/// An <see cref="IImageProcessor{TColor, TPacked}"/> to change the hue of an <see cref="Image{TColor, TPacked}"/>.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
@ -18,12 +18,7 @@ namespace ImageProcessorCore.Processors
where TPacked : struct
{
/// <summary>
/// The <see cref="Matrix4x4"/> used to alter the image.
/// </summary>
private Matrix4x4 matrix;
/// <summary>
/// Initializes a new instance of the <see cref="HueProcessor"/> class.
/// Initializes a new instance of the <see cref="HueProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="angle">The new brightness of the image. Must be between -100 and 100.</param>
public HueProcessor(float angle)
@ -67,7 +62,7 @@ namespace ImageProcessorCore.Processors
M33 = (float)(lumB + (cosradians * oneMinusLumB) + (sinradians * lumB))
};
this.matrix = matrix4X4;
this.Matrix = matrix4X4;
}
/// <summary>
@ -76,7 +71,7 @@ namespace ImageProcessorCore.Processors
public float Angle { get; }
/// <inheritdoc/>
public override Matrix4x4 Matrix => this.matrix;
public override Matrix4x4 Matrix { get; }
/// <inheritdoc/>
public override bool Compand => false;

2
src/ImageProcessorCore/Filters/Processors/ColorMatrix/IColorMatrixFilter.cs

@ -11,6 +11,8 @@ namespace ImageProcessorCore.Processors
/// Encapsulates properties and methods for creating processors that utilize a matrix to
/// alter the image pixels.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public interface IColorMatrixFilter<TColor, TPacked> : IImageProcessor<TColor, TPacked>
where TColor : IPackedVector<TPacked>
where TPacked : struct

2
src/ImageProcessorCore/Filters/Processors/ColorMatrix/PolaroidProcessor.cs

@ -45,4 +45,4 @@ namespace ImageProcessorCore.Processors
new GlowProcessor<TColor, TPacked> { GlowColor = packedG, Radius = target.Width / 4F }.Apply(target, target, sourceRectangle);
}
}
}
}

24
src/ImageProcessorCore/Filters/Processors/ColorMatrix/SaturationProcessor.cs

@ -8,7 +8,7 @@ namespace ImageProcessorCore.Processors
using System.Numerics;
/// <summary>
/// An <see cref="IImageProcessor{TColor, TPacked}"/> to change the saturation of an <see cref="Image"/>.
/// An <see cref="IImageProcessor{TColor, TPacked}"/> to change the saturation of an <see cref="Image{TColor, TPacked}"/>.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
@ -17,28 +17,16 @@ namespace ImageProcessorCore.Processors
where TPacked : struct
{
/// <summary>
/// The saturation to be applied to the image.
/// </summary>
private readonly int saturation;
/// <summary>
/// The <see cref="Matrix4x4"/> used to alter the image.
/// </summary>
private Matrix4x4 matrix;
/// <summary>
/// Initializes a new instance of the <see cref="SaturationProcessor"/> class.
/// Initializes a new instance of the <see cref="SaturationProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="saturation">The new saturation of the image. Must be between -100 and 100.</param>
/// <exception cref="ArgumentException">
/// <exception cref="System.ArgumentException">
/// <paramref name="saturation"/> is less than -100 or is greater than 100.
/// </exception>
public SaturationProcessor(int saturation)
{
Guard.MustBeBetweenOrEqualTo(saturation, -100, 100, nameof(saturation));
this.saturation = saturation;
float saturationFactor = this.saturation / 100f;
float saturationFactor = saturation / 100f;
// Stop at -1 to prevent inversion.
saturationFactor++;
@ -65,10 +53,10 @@ namespace ImageProcessorCore.Processors
M33 = saturationComplementB + saturationFactor,
};
this.matrix = matrix4X4;
this.Matrix = matrix4X4;
}
/// <inheritdoc/>
public override Matrix4x4 Matrix => this.matrix;
public override Matrix4x4 Matrix { get; }
}
}

2
src/ImageProcessorCore/Filters/Processors/ColorMatrix/SepiaProcessor.cs

@ -34,4 +34,4 @@ namespace ImageProcessorCore.Processors
/// <inheritdoc/>
public override bool Compand => false;
}
}
}

8
src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs

@ -12,17 +12,17 @@ namespace ImageProcessorCore.Processors
/// <summary>
/// An <see cref="IImageProcessor{TColor, TPacked}"/> to change the contrast of an <see cref="Image{TColor, TPacked}"/>.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>long, float.</example></typeparam>
public class ContrastProcessor<TColor, TPacked> : ImageProcessor<TColor, TPacked>
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
/// <summary>
/// Initializes a new instance of the <see cref="ContrastProcessor"/> class.
/// Initializes a new instance of the <see cref="ContrastProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="contrast">The new contrast of the image. Must be between -100 and 100.</param>
/// <exception cref="ArgumentException">
/// <exception cref="System.ArgumentException">
/// <paramref name="contrast"/> is less than -100 or is greater than 100.
/// </exception>
public ContrastProcessor(int contrast)

2
src/ImageProcessorCore/Filters/Processors/Convolution/BoxBlurProcessor.cs

@ -30,7 +30,7 @@ namespace ImageProcessorCore.Processors
private float[,] kernelX;
/// <summary>
/// Initializes a new instance of the <see cref="GuassianBlurProcessor"/> class.
/// Initializes a new instance of the <see cref="BoxBlurProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="radius">
/// The 'radius' value representing the size of the area to sample.

2
src/ImageProcessorCore/Filters/Processors/Convolution/ConvolutionFilter.cs

@ -11,6 +11,8 @@ namespace ImageProcessorCore.Processors
/// <summary>
/// Defines a filter that uses a 2 dimensional matrix to perform convolution against an image.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public abstract class ConvolutionFilter<TColor, TPacked> : ImageProcessor<TColor, TPacked>
where TColor : IPackedVector<TPacked>
where TPacked : struct

2
src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/EdgeDetector2DFilter.cs

@ -9,6 +9,8 @@ namespace ImageProcessorCore.Processors
/// Defines a filter that detects edges within an image using two
/// one-dimensional matrices.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public abstract class EdgeDetector2DFilter<TColor, TPacked> : Convolution2DFilter<TColor, TPacked>, IEdgeDetectorFilter<TColor, TPacked>
where TColor : IPackedVector<TPacked>
where TPacked : struct

2
src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/EdgeDetectorFilter.cs

@ -9,6 +9,8 @@ namespace ImageProcessorCore.Processors
/// Defines a filter that detects edges within an image using a single
/// two dimensional matrix.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public abstract class EdgeDetectorFilter<TColor, TPacked> : ConvolutionFilter<TColor, TPacked>, IEdgeDetectorFilter<TColor, TPacked>
where TColor : IPackedVector<TPacked>
where TPacked : struct

2
src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/IEdgeDetectorFilter.cs

@ -8,6 +8,8 @@ namespace ImageProcessorCore.Processors
/// <summary>
/// Provides properties and methods allowing the detection of edges within an image.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public interface IEdgeDetectorFilter<TColor, TPacked> : IImageProcessor<TColor, TPacked>, IEdgeDetectorFilter
where TColor : IPackedVector<TPacked>
where TPacked : struct

6
src/ImageProcessorCore/Filters/Processors/Convolution/GuassianBlurProcessor.cs

@ -37,7 +37,7 @@ namespace ImageProcessorCore.Processors
private float[,] kernelX;
/// <summary>
/// Initializes a new instance of the <see cref="GuassianBlurProcessor"/> class.
/// Initializes a new instance of the <see cref="GuassianBlurProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
public GuassianBlurProcessor(float sigma = 3f)
@ -47,7 +47,7 @@ namespace ImageProcessorCore.Processors
}
/// <summary>
/// Initializes a new instance of the <see cref="GuassianBlurProcessor"/> class.
/// Initializes a new instance of the <see cref="GuassianBlurProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="radius">
/// The 'radius' value representing the size of the area to sample.
@ -59,7 +59,7 @@ namespace ImageProcessorCore.Processors
}
/// <summary>
/// Initializes a new instance of the <see cref="GuassianBlurProcessor"/> class.
/// Initializes a new instance of the <see cref="GuassianBlurProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="sigma">
/// The 'sigma' value representing the weight of the blur.

6
src/ImageProcessorCore/Filters/Processors/Convolution/GuassianSharpenProcessor.cs

@ -37,7 +37,7 @@ namespace ImageProcessorCore.Processors
private float[,] kernelX;
/// <summary>
/// Initializes a new instance of the <see cref="GuassianSharpenProcessor"/> class.
/// Initializes a new instance of the <see cref="GuassianSharpenProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="sigma">
/// The 'sigma' value representing the weight of the sharpening.
@ -49,7 +49,7 @@ namespace ImageProcessorCore.Processors
}
/// <summary>
/// Initializes a new instance of the <see cref="GuassianSharpenProcessor"/> class.
/// Initializes a new instance of the <see cref="GuassianSharpenProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="radius">
/// The 'radius' value representing the size of the area to sample.
@ -61,7 +61,7 @@ namespace ImageProcessorCore.Processors
}
/// <summary>
/// Initializes a new instance of the <see cref="GuassianSharpenProcessor"/> class.
/// Initializes a new instance of the <see cref="GuassianSharpenProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="sigma">
/// The 'sigma' value representing the weight of the sharpen.

6
src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs

@ -15,11 +15,11 @@ namespace ImageProcessorCore.Processors
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public class GlowProcessor<TColor, TPacked> : ImageProcessor<TColor, TPacked>
where TColor : IPackedVector<TPacked>
where TPacked : struct
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
/// <summary>
/// Initializes a new instance of the <see cref="GlowProcessor{TColor, TPacked}"/> class.
/// Initializes a new instance of the <see cref="GlowProcessor{T,TP}"/> class.
/// </summary>
public GlowProcessor()
{

4
src/ImageProcessorCore/Filters/Processors/PixelateProcessor.cs

@ -19,7 +19,7 @@ namespace ImageProcessorCore.Processors
where TPacked : struct
{
/// <summary>
/// Initializes a new instance of the <see cref="PixelateProcessor{TColor, TPacked}"/> class.
/// Initializes a new instance of the <see cref="PixelateProcessor{T,TP}"/> class.
/// </summary>
/// <param name="size">The size of the pixels. Must be greater than 0.</param>
/// <exception cref="System.ArgumentException">
@ -110,4 +110,4 @@ namespace ImageProcessorCore.Processors
}
}
}
}
}

3
src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs

@ -96,5 +96,4 @@ namespace ImageProcessorCore.Processors
}
}
}
}
}

2
src/ImageProcessorCore/Filters/Sepia.cs

@ -55,4 +55,4 @@ namespace ImageProcessorCore
}
}
}
}
}

4
src/ImageProcessorCore/Formats/Bmp/BmpDecoder.cs

@ -71,8 +71,8 @@ namespace ImageProcessorCore.Formats
/// <inheritdoc/>
public void Decode<TColor, TPacked>(Image<TColor, TPacked> image, Stream stream)
where TColor : IPackedVector<TPacked>
where TPacked : struct
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
Guard.NotNull(image, "image");
Guard.NotNull(stream, "stream");

11
src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs

@ -128,8 +128,7 @@ namespace ImageProcessorCore.Formats
case BmpCompression.RGB:
if (this.infoHeader.HeaderSize != 40)
{
throw new ImageFormatException(
$"Header Size value '{this.infoHeader.HeaderSize}' is not valid.");
throw new ImageFormatException($"Header Size value '{this.infoHeader.HeaderSize}' is not valid.");
}
if (this.infoHeader.BitsPerPixel == 32)
@ -190,7 +189,7 @@ namespace ImageProcessorCore.Formats
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="imageData">The <see cref="T:TColor[]"/> image data to assign the palette to.</param>
/// <param name="imageData">The <see cref="T:T[]"/> image data to assign the palette to.</param>
/// <param name="colors">The <see cref="T:byte[]"/> containing the colors.</param>
/// <param name="width">The width of the bitmap.</param>
/// <param name="height">The height of the bitmap.</param>
@ -255,7 +254,7 @@ namespace ImageProcessorCore.Formats
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="imageData">The <see cref="T:TColor[]"/> image data to assign the palette to.</param>
/// <param name="imageData">The <see cref="T:T[]"/> image data to assign the palette to.</param>
/// <param name="width">The width of the bitmap.</param>
/// <param name="height">The height of the bitmap.</param>
/// <param name="inverted">Whether the bitmap is inverted.</param>
@ -306,7 +305,7 @@ namespace ImageProcessorCore.Formats
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="imageData">The <see cref="T:TColor[]"/> image data to assign the palette to.</param>
/// <param name="imageData">The <see cref="T:T[]"/> image data to assign the palette to.</param>
/// <param name="width">The width of the bitmap.</param>
/// <param name="height">The height of the bitmap.</param>
/// <param name="inverted">Whether the bitmap is inverted.</param>
@ -347,7 +346,7 @@ namespace ImageProcessorCore.Formats
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="imageData">The <see cref="T:TColor[]"/> image data to assign the palette to.</param>
/// <param name="imageData">The <see cref="T:T[]"/> image data to assign the palette to.</param>
/// <param name="width">The width of the bitmap.</param>
/// <param name="height">The height of the bitmap.</param>
/// <param name="inverted">Whether the bitmap is inverted.</param>

15
src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs

@ -27,8 +27,8 @@ namespace ImageProcessorCore.Formats
/// <summary>
/// Encodes the image to the specified stream from the <see cref="ImageBase{TColor, TPacked}"/>.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>long, float.</example></typeparam>
/// <param name="image">The <see cref="ImageBase{TColor, TPacked}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
/// <param name="bitsPerPixel">The <see cref="BmpBitsPerPixel"/></param>
@ -134,11 +134,11 @@ namespace ImageProcessorCore.Formats
switch (this.bmpBitsPerPixel)
{
case BmpBitsPerPixel.Pixel32:
this.Write32Bit(writer, pixels);
this.Write32Bit<TColor, TPacked>(writer, pixels);
break;
case BmpBitsPerPixel.Pixel24:
this.Write24Bit(writer, pixels);
this.Write24Bit<TColor, TPacked>(writer, pixels);
break;
}
}
@ -150,7 +150,7 @@ namespace ImageProcessorCore.Formats
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="writer">The <see cref="EndianBinaryWriter"/> containing the stream to write to.</param>
/// <param name="pixels">The <see cref="IPixelAccessor"/> containing pixel data.</param>
/// <param name="pixels">The <see cref="PixelAccessor{TColor,TPacked}"/> containing pixel data.</param>
private void Write32Bit<TColor, TPacked>(EndianBinaryWriter writer, PixelAccessor<TColor, TPacked> pixels)
where TColor : IPackedVector<TPacked>
where TPacked : struct
@ -176,8 +176,9 @@ namespace ImageProcessorCore.Formats
/// Writes the 24bit color palette to the stream.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>/// <param name="writer">The <see cref="EndianBinaryWriter"/> containing the stream to write to.</param>
/// <param name="pixels">The <see cref="IPixelAccessor"/> containing pixel data.</param>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="writer">The <see cref="EndianBinaryWriter"/> containing the stream to write to.</param>
/// <param name="pixels">The <see cref="PixelAccessor{TColor,TPacked}"/> containing pixel data.</param>
private void Write24Bit<TColor, TPacked>(EndianBinaryWriter writer, PixelAccessor<TColor, TPacked> pixels)
where TColor : IPackedVector<TPacked>
where TPacked : struct

2
src/ImageProcessorCore/Formats/Gif/GifDecoderCore.cs

@ -12,7 +12,7 @@ namespace ImageProcessorCore.Formats
/// Performs the gif decoding operation.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
internal class GifDecoderCore<TColor, TPacked>
where TColor : IPackedVector<TPacked>
where TPacked : struct

1
src/ImageProcessorCore/Formats/Gif/LzwDecoder.cs

@ -5,7 +5,6 @@
namespace ImageProcessorCore.Formats
{
using System;
using System.IO;
/// <summary>

2
src/ImageProcessorCore/Formats/Gif/LzwEncoder.cs

@ -310,7 +310,7 @@ namespace ImageProcessorCore.Formats
}
/// <summary>
/// Return the nexTColor pixel from the image
/// Return the next pixel from the image
/// </summary>
/// <returns>
/// The <see cref="int"/>

2
src/ImageProcessorCore/Formats/Gif/Sections/GifGraphicsControlExtension.cs

@ -27,7 +27,7 @@ namespace ImageProcessorCore.Formats
/// <summary>
/// Gets or sets the transparency index.
/// The Transparency Index is such that when encountered, the corresponding pixel
/// of the display device is not modified and processing goes on to the nexTColor pixel.
/// of the display device is not modified and processing goes on to the next pixel.
/// </summary>
public int TransparencyIndex { get; set; }

4
src/ImageProcessorCore/Formats/IImageEncoder.cs

@ -38,11 +38,11 @@ namespace ImageProcessorCore.Formats
bool IsSupportedFileExtension(string extension);
/// <summary>
/// Encodes the image to the specified stream from the <see cref="Image{T,P}"/>.
/// Encodes the image to the specified stream from the <see cref="Image{TColor, TPacked}"/>.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="image">The <see cref="Image{T,P}"/> to encode from.</param>
/// <param name="image">The <see cref="Image{TColor, TPacked}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
void Encode<TColor, TPacked>(Image<TColor, TPacked> image, Stream stream)
where TColor : IPackedVector<TPacked>

2
src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id

@ -1 +1 @@
d6ce5dd6236ac6ef9ba570fb4e57e81c06bbb854
457ce2b70d772a8f3b259b2d624fcb41c75357e1

10
src/ImageProcessorCore/Formats/Jpg/JpegEncoderCore.cs

@ -504,7 +504,7 @@ namespace ImageProcessorCore.Formats
// Write the image data.
using (PixelAccessor<TColor, TPacked> pixels = image.Lock())
{
this.WriteSOS(pixels);
this.WriteSOS<TColor, TPacked>(pixels);
}
// Write the End Of Image marker.
@ -720,10 +720,10 @@ namespace ImageProcessorCore.Formats
switch (this.subsample)
{
case JpegSubsample.Ratio444:
this.Encode444(pixels);
this.Encode444<TColor, TPacked>(pixels);
break;
case JpegSubsample.Ratio420:
this.Encode420(pixels);
this.Encode420<TColor, TPacked>(pixels);
break;
}
@ -750,7 +750,7 @@ namespace ImageProcessorCore.Formats
{
for (int x = 0; x < pixels.Width; x += 8)
{
this.ToYCbCr(pixels, x, y, b, cb, cr);
this.ToYCbCr<TColor, TPacked>(pixels, x, y, b, cb, cr);
prevDCY = this.WriteBlock(b, QuantIndex.Luminance, prevDCY);
prevDCCb = this.WriteBlock(cb, QuantIndex.Chrominance, prevDCCb);
prevDCCr = this.WriteBlock(cr, QuantIndex.Chrominance, prevDCCr);
@ -784,7 +784,7 @@ namespace ImageProcessorCore.Formats
int xOff = (i & 1) * 8;
int yOff = (i & 2) * 4;
this.ToYCbCr(pixels, x + xOff, y + yOff, b, cb[i], cr[i]);
this.ToYCbCr<TColor, TPacked>(pixels, x + xOff, y + yOff, b, cb[i], cr[i]);
prevDCY = this.WriteBlock(b, QuantIndex.Luminance, prevDCY);
}

2
src/ImageProcessorCore/Formats/Png/Filters/UpFilter.cs

@ -6,7 +6,7 @@
namespace ImageProcessorCore.Formats
{
/// <summary>
/// The Up filter is just like the Sub filter except that the pixel immediately above the currenTColor pixel,
/// The Up filter is just like the Sub filter except that the pixel immediately above the current pixel,
/// rather than just to its left, is used as the predictor.
/// <see href="https://www.w3.org/TR/PNG-Filters.html"/>
/// </summary>

2
src/ImageProcessorCore/Formats/Png/PngDecoder.cs

@ -77,6 +77,8 @@ namespace ImageProcessorCore.Formats
/// <summary>
/// Decodes the image from the specified stream to the <see cref="ImageBase{TColor, TPacked}"/>.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="image">The <see cref="ImageBase{TColor, TPacked}"/> to decode to.</param>
/// <param name="stream">The <see cref="Stream"/> containing image data.</param>
public void Decode<TColor, TPacked>(Image<TColor, TPacked> image, Stream stream)

13
src/ImageProcessorCore/Formats/Png/PngDecoderCore.cs

@ -81,13 +81,13 @@ namespace ImageProcessorCore.Formats
/// Decodes the stream to the image.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="image">The image to decode to.</param>
/// <param name="stream">The stream containing image data. </param>
/// <exception cref="ImageFormatException">
/// Thrown if the stream does not contain and end chunk.
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown if the image is larger than the maximum allowable size.
/// </exception>
public void Decode<TColor, TPacked>(Image<TColor, TPacked> image, Stream stream)
@ -150,11 +150,7 @@ namespace ImageProcessorCore.Formats
}
TColor[] pixels = new TColor[this.header.Width * this.header.Height];
this.ReadScanlines<TColor, TPacked>(dataStream, pixels);
image.SetPixels(this.header.Width, this.header.Height, pixels);
}
}
@ -226,9 +222,10 @@ namespace ImageProcessorCore.Formats
/// <summary>
/// Reads the scanlines within the image.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="dataStream">The <see cref="MemoryStream"/> containing data.</param>
/// <param name="pixels">
/// The <see cref="T:floaTColor[]"/> containing pixel data.</param>
/// <param name="pixels"> The pixel data.</param>
private void ReadScanlines<TColor, TPacked>(MemoryStream dataStream, TColor[] pixels)
where TColor : IPackedVector<TPacked>
where TPacked : struct

4
src/ImageProcessorCore/Formats/Png/PngEncoder.cs

@ -73,8 +73,8 @@ namespace ImageProcessorCore.Formats
/// <inheritdoc/>
public void Encode<TColor, TPacked>(Image<TColor, TPacked> image, Stream stream)
where TColor : IPackedVector<TPacked>
where TPacked : struct
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
PngEncoderCore encoder = new PngEncoderCore
{

2
src/ImageProcessorCore/IO/EndianBitConverter.cs

@ -246,7 +246,7 @@ namespace ImageProcessorCore.IO
/// <param name="startIndex">The start index passed in</param>
/// <param name="bytesRequired">The number of bytes required</param>
/// <exception cref="System.ArgumentNullException">value is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">
/// <exception cref="System.ArgumentOutOfRangeException">
/// startIndex is less than zero or greater than the length of value minus bytesRequired.
/// </exception>
[SuppressMessage("ReSharper", "UnusedParameter.Local", Justification = "Keeps code DRY")]

12
src/ImageProcessorCore/Image/IImageBase.cs

@ -5,8 +5,6 @@
namespace ImageProcessorCore
{
using System;
/// <summary>
/// Encapsulates the basic properties and methods required to manipulate images in varying formats.
/// </summary>
@ -27,10 +25,10 @@ namespace ImageProcessorCore
/// <param name="width">The new width of the image. Must be greater than zero.</param>
/// <param name="height">The new height of the image. Must be greater than zero.</param>
/// <param name="pixels">The array with pixels. Must be a multiple of the width and height.</param>
/// <exception cref="ArgumentOutOfRangeException">
/// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown if either <paramref name="width"/> or <paramref name="height"/> are less than or equal to 0.
/// </exception>
/// <exception cref="ArgumentException">
/// <exception cref="System.ArgumentException">
/// Thrown if the <paramref name="pixels"/> length is not equal to Width * Height.
/// </exception>
void SetPixels(int width, int height, TColor[] pixels);
@ -42,10 +40,10 @@ namespace ImageProcessorCore
/// <param name="width">The new width of the image. Must be greater than zero.</param>
/// <param name="height">The new height of the image. Must be greater than zero.</param>
/// <param name="pixels">The array with pixels. Must be a multiple of four times the width and height.</param>
/// <exception cref="ArgumentOutOfRangeException">
/// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown if either <paramref name="width"/> or <paramref name="height"/> are less than or equal to 0.
/// </exception>
/// <exception cref="ArgumentException">
/// <exception cref="System.ArgumentException">
/// Thrown if the <paramref name="pixels"/> length is not equal to Width * Height.
/// </exception>
void ClonePixels(int width, int height, TColor[] pixels);
@ -56,7 +54,7 @@ namespace ImageProcessorCore
/// It is imperative that the accessor is correctly disposed off after use.
/// </remarks>
/// </summary>
/// <returns>The <see cref="IPixelAccessor"/></returns>
/// <returns>The <see cref="PixelAccessor{TColor,TPacked}"/></returns>
PixelAccessor<TColor, TPacked> Lock();
}

4
src/ImageProcessorCore/Image/IImageProcessor.cs

@ -44,7 +44,7 @@ namespace ImageProcessorCore.Processors
bool Compand { get; set; }
/// <summary>
/// Applies the process to the specified portion of the specified <see cref="ImageBase{TColor, TPacked}"/>.
/// Applies the process to the specified portion of the specified <see cref="ImageBase{T, TP}"/>.
/// </summary>
/// <param name="target">Target image to apply the process to.</param>
/// <param name="source">The source image. Cannot be null.</param>
@ -64,7 +64,7 @@ namespace ImageProcessorCore.Processors
void Apply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle sourceRectangle);
/// <summary>
/// Applies the process to the specified portion of the specified <see cref="ImageBase{TColor, TPacked}"/> at the specified
/// Applies the process to the specified portion of the specified <see cref="ImageBase{T, TP}"/> at the specified
/// location and with the specified size.
/// </summary>
/// <param name="target">Target image to apply the process to.</param>

53
src/ImageProcessorCore/Image/ImageBase.cs

@ -3,8 +3,6 @@
// Licensed under the Apache License, Version 2.0.
// </copyright>
using System.Runtime.CompilerServices;
namespace ImageProcessorCore
{
using System;
@ -12,20 +10,15 @@ namespace ImageProcessorCore
/// <summary>
/// The base class of all images. Encapsulates the basic properties and methods required to manipulate
/// images in differenTColor pixel formats.
/// images in different pixel formats.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
[DebuggerDisplay("Image: {Width}x{Height}")]
public abstract unsafe class ImageBase<TColor, TPacked> : IImageBase<TColor, TPacked>
public abstract class ImageBase<TColor, TPacked> : IImageBase<TColor, TPacked>
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
/// <summary>
/// The image pixels
/// </summary>
private TColor[] pixelBuffer;
/// <summary>
/// Initializes a new instance of the <see cref="ImageBase{TColor, TPacked}"/> class.
/// </summary>
@ -38,7 +31,7 @@ namespace ImageProcessorCore
/// </summary>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <exception cref="ArgumentOutOfRangeException">
/// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown if either <paramref name="width"/> or <paramref name="height"/> are less than or equal to 0.
/// </exception>
protected ImageBase(int width, int height)
@ -48,7 +41,7 @@ namespace ImageProcessorCore
this.Width = width;
this.Height = height;
this.pixelBuffer = new TColor[width * height];
this.Pixels = new TColor[width * height];
}
/// <summary>
@ -68,9 +61,9 @@ namespace ImageProcessorCore
this.Height = other.Height;
this.CopyProperties(other);
// Copy the pixels.
this.pixelBuffer = new TColor[this.Width * this.Height];
Unsafe.Copy(Unsafe.AsPointer(ref this.pixelBuffer), ref other.pixelBuffer);
// Copy the pixels. Don't use Unsafe.Copy as it is breaking edge detection.
this.Pixels = new TColor[this.Width * this.Height];
Array.Copy(other.Pixels, this.Pixels, other.Pixels.Length);
}
/// <inheritdoc/>
@ -80,7 +73,7 @@ namespace ImageProcessorCore
public int MaxHeight { get; set; } = int.MaxValue;
/// <inheritdoc/>
public TColor[] Pixels => this.pixelBuffer;
public TColor[] Pixels { get; private set; }
/// <inheritdoc/>
public int Width { get; private set; }
@ -103,15 +96,8 @@ namespace ImageProcessorCore
/// <inheritdoc/>
public void SetPixels(int width, int height, TColor[] pixels)
{
if (width <= 0)
{
throw new ArgumentOutOfRangeException(nameof(width), "Width must be greater than or equals than zero.");
}
if (height <= 0)
{
throw new ArgumentOutOfRangeException(nameof(height), "Height must be greater than or equal than zero.");
}
Guard.MustBeGreaterThan(width, 0, nameof(width));
Guard.MustBeGreaterThan(height, 0, nameof(height));
if (pixels.Length != width * height)
{
@ -120,21 +106,14 @@ namespace ImageProcessorCore
this.Width = width;
this.Height = height;
this.pixelBuffer = pixels;
this.Pixels = pixels;
}
/// <inheritdoc/>
public void ClonePixels(int width, int height, TColor[] pixels)
{
if (width <= 0)
{
throw new ArgumentOutOfRangeException(nameof(width), "Width must be greater than or equals than zero.");
}
if (height <= 0)
{
throw new ArgumentOutOfRangeException(nameof(height), "Height must be greater than or equal than zero.");
}
Guard.MustBeGreaterThan(width, 0, nameof(width));
Guard.MustBeGreaterThan(height, 0, nameof(height));
if (pixels.Length != width * height)
{
@ -144,9 +123,9 @@ namespace ImageProcessorCore
this.Width = width;
this.Height = height;
// Copy the pixels.
this.pixelBuffer = new TColor[pixels.Length];
Unsafe.Copy(Unsafe.AsPointer(ref this.pixelBuffer), ref pixels);
// Copy the pixels. Don't use Unsafe.Copy as it is breaking edge detection.
this.Pixels = new TColor[pixels.Length];
Array.Copy(pixels, this.Pixels, pixels.Length);
}
/// <inheritdoc/>

20
src/ImageProcessorCore/Image/ImageExtensions.cs

@ -20,7 +20,7 @@ namespace ImageProcessorCore
/// Saves the image to the given stream with the bmp format.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
@ -34,7 +34,7 @@ namespace ImageProcessorCore
/// Saves the image to the given stream with the png format.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="quality">The quality to save the image to representing the number of colors.
@ -50,7 +50,7 @@ namespace ImageProcessorCore
/// Saves the image to the given stream with the jpeg format.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="quality">The quality to save the image to. Between 1 and 100.</param>
@ -64,7 +64,7 @@ namespace ImageProcessorCore
/// Saves the image to the given stream with the gif format.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="quality">The quality to save the image to representing the number of colors. Between 1 and 256.</param>
@ -115,8 +115,8 @@ namespace ImageProcessorCore
/// This method is not chainable.
/// </remarks>
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>long, float.</example></typeparam>
/// <param name="source">The source image. Cannot be null.</param>
/// <param name="width">The target image width.</param>
/// <param name="height">The target image height.</param>
@ -135,8 +135,8 @@ namespace ImageProcessorCore
/// This method does will resize the target image if the source and target rectangles are different.
/// </remarks>
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>long, float.</example></typeparam>
/// <param name="source">The source image. Cannot be null.</param>
/// <param name="width">The target image width.</param>
/// <param name="height">The target image height.</param>
@ -159,8 +159,8 @@ namespace ImageProcessorCore
/// <summary>
/// Performs the given action on the source image.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>long, float.</example></typeparam>
/// <param name="source">The image to perform the action against.</param>
/// <param name="clone">Whether to clone the image.</param>
/// <param name="action">The <see cref="Action"/> to perform against the image.</param>

3
src/ImageProcessorCore/Image/PixelAccessor.cs

@ -14,7 +14,7 @@ namespace ImageProcessorCore
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public sealed unsafe class PixelAccessor<TColor, TPacked> : IDisposable
public unsafe class PixelAccessor<TColor, TPacked> : IDisposable
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
@ -106,6 +106,7 @@ namespace ImageProcessorCore
{
get { return Unsafe.Read<TColor>(this.pixelsBase + (y * this.Width + x) * Unsafe.SizeOf<TColor>()); }
set { Unsafe.Write(this.pixelsBase + (y * this.Width + x) * Unsafe.SizeOf<TColor>(), value); }
}
/// <summary>

4
src/ImageProcessorCore/ImageProcessor.cs

@ -12,6 +12,8 @@ namespace ImageProcessorCore.Processors
/// <summary>
/// Allows the application of processors to images.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public abstract class ImageProcessor<TColor, TPacked> : IImageProcessor<TColor, TPacked>
where TColor : IPackedVector<TPacked>
where TPacked : struct
@ -93,8 +95,6 @@ namespace ImageProcessorCore.Processors
/// <summary>
/// This method is called before the process is applied to prepare the processor.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="target">Target image to apply the process to.</param>
/// <param name="source">The source image. Cannot be null.</param>
/// <param name="targetRectangle">

2
src/ImageProcessorCore/Profiles/Exif/ExifProfile.cs

@ -2,9 +2,9 @@
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageProcessorCore
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;

2
src/ImageProcessorCore/Quantizers/IQuantizer.cs

@ -15,7 +15,7 @@ namespace ImageProcessorCore.Quantizers
where TPacked : struct
{
/// <summary>
/// Quantize an image and return the resulting outpuTColor pixels.
/// Quantize an image and return the resulting output pixels.
/// </summary>
/// <param name="image">The image to quantize.</param>
/// <param name="maxColors">The maximum number of colors to return.</param>

32
src/ImageProcessorCore/Quantizers/Octree/OctreeQuantizer.cs

@ -74,9 +74,7 @@ namespace ImageProcessorCore.Quantizers
/// <summary>
/// Override this to process the pixel in the second pass of the algorithm
/// </summary>
/// <param name="pixel">
/// The pixel to quantize
/// </param>
/// <param name="pixel">The pixel to quantize</param>
/// <returns>
/// The quantized value
/// </returns>
@ -193,7 +191,7 @@ namespace ImageProcessorCore.Quantizers
/// Add a given color value to the Octree
/// </summary>
/// <param name="pixel">
/// The <see cref="T"/>containing color information to add.
/// The <see cref="TColor"/>containing color information to add.
/// </param>
public void AddColor(TColor pixel)
{
@ -224,11 +222,9 @@ namespace ImageProcessorCore.Quantizers
/// <summary>
/// Convert the nodes in the Octree to a palette with a maximum of colorCount colors
/// </summary>
/// <param name="colorCount">
/// The maximum number of colors
/// </param>
/// <param name="colorCount">The maximum number of colors</param>
/// <returns>
/// An <see cref="List{T}"/> with the palletized colors
/// An <see cref="List{TColor}"/> with the palletized colors
/// </returns>
public List<TColor> Palletize(int colorCount)
{
@ -249,9 +245,7 @@ namespace ImageProcessorCore.Quantizers
/// <summary>
/// Get the palette index for the passed color
/// </summary>
/// <param name="pixel">
/// The <see cref="T"/> containing the pixel data.
/// </param>
/// <param name="pixel">The <see cref="TColor"/> containing the pixel data.</param>
/// <returns>
/// The index of the given structure.
/// </returns>
@ -449,12 +443,8 @@ namespace ImageProcessorCore.Quantizers
/// <summary>
/// Traverse the tree, building up the color palette
/// </summary>
/// <param name="palette">
/// The palette
/// </param>
/// <param name="index">
/// The current palette index
/// </param>
/// <param name="palette">The palette</param>
/// <param name="index">The current palette index</param>
public void ConstructPalette(List<TColor> palette, ref int index)
{
if (this.leaf)
@ -487,12 +477,8 @@ namespace ImageProcessorCore.Quantizers
/// <summary>
/// Return the palette index for the passed color
/// </summary>
/// <param name="pixel">
/// The <see cref="T"/> representing the pixel.
/// </param>
/// <param name="level">
/// The level.
/// </param>
/// <param name="pixel">The <see cref="TColor"/> representing the pixel.</param>
/// <param name="level">The level.</param>
/// <returns>
/// The <see cref="int"/> representing the index of the pixel in the palette.
/// </returns>

6
src/ImageProcessorCore/Quantizers/Octree/Quantizer.cs

@ -11,6 +11,8 @@ namespace ImageProcessorCore.Quantizers
/// <summary>
/// Encapsulates methods to calculate the color palette of an image.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public abstract class Quantizer<TColor, TPacked> : IQuantizer<TColor, TPacked>
where TColor : IPackedVector<TPacked>
where TPacked : struct
@ -98,10 +100,10 @@ namespace ImageProcessorCore.Quantizers
/// Execute a second pass through the bitmap
/// </summary>
/// <param name="source">The source image.</param>
/// <param name="output">The outpuTColor pixel array</param>
/// <param name="output">The output pixel array</param>
/// <param name="width">The width in pixels of the image</param>
/// <param name="height">The height in pixels of the image</param>
protected virtual void SecondPass(PixelAccessor<TColor, TPacked> source, byte[] output, int width, int height)
protected virtual void SecondPass(PixelAccessor<TColor,TPacked> source, byte[] output, int width, int height)
{
Parallel.For(
0,

4
src/ImageProcessorCore/Quantizers/Quantize.cs

@ -3,10 +3,10 @@
// Licensed under the Apache License, Version 2.0.
// </copyright>
using ImageProcessorCore.Quantizers;
namespace ImageProcessorCore
{
using ImageProcessorCore.Quantizers;
/// <summary>
/// Extension methods for the <see cref="Image{TColor, TPacked}"/> type.
/// </summary>

4
src/ImageProcessorCore/Quantizers/QuantizedImage.cs

@ -14,8 +14,8 @@ namespace ImageProcessorCore.Quantizers
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public class QuantizedImage<TColor, TPacked>
where TColor : IPackedVector<TPacked>
where TPacked : struct
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
/// <summary>
/// Initializes a new instance of the <see cref="QuantizedImage{TColor, TPacked}"/> class.

2
src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs

@ -102,7 +102,7 @@ namespace ImageProcessorCore.Quantizers
private readonly byte[] tag;
/// <summary>
/// Initializes a new instance of the <see cref="WuQuantizer{TColor, TPacked}"/> class.
/// Initializes a new instance of the <see cref="WuQuantizer{T,TP}"/> class.
/// </summary>
public WuQuantizer()
{

31
src/ImageProcessorCore/Samplers/AutoOrient.cs

@ -17,7 +17,7 @@ namespace ImageProcessorCore
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image to crop.</param>
/// <param name="source">The image to auto rotate.</param>
/// <returns>The <see cref="Image"/></returns>
public static Image<TColor, TPacked> AutoOrient<TColor, TPacked>(this Image<TColor, TPacked> source, ProgressEventHandler progressHandler = null)
where TColor : IPackedVector<TPacked>
@ -27,11 +27,6 @@ namespace ImageProcessorCore
switch (orientation)
{
case Orientation.Unknown:
case Orientation.TopLeft:
default:
return source;
case Orientation.TopRight:
return source.Flip(FlipType.Horizontal, progressHandler);
@ -42,23 +37,33 @@ namespace ImageProcessorCore
return source.Flip(FlipType.Vertical, progressHandler);
case Orientation.LeftTop:
return source
.Rotate(RotateType.Rotate90, progressHandler)
.Flip(FlipType.Horizontal, progressHandler);
return source.Rotate(RotateType.Rotate90, progressHandler)
.Flip(FlipType.Horizontal, progressHandler);
case Orientation.RightTop:
return source.Rotate(RotateType.Rotate90, progressHandler);
case Orientation.RightBottom:
return source
.Flip(FlipType.Vertical, progressHandler)
.Rotate(RotateType.Rotate270, progressHandler);
return source.Flip(FlipType.Vertical, progressHandler)
.Rotate(RotateType.Rotate270, progressHandler);
case Orientation.LeftBottom:
return source.Rotate(RotateType.Rotate270, progressHandler);
case Orientation.Unknown:
case Orientation.TopLeft:
default:
return source;
}
}
/// <summary>
/// Returns the current EXIF orientation
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image to auto rotate.</param>
/// <returns>The <see cref="Orientation"/></returns>
private static Orientation GetExifOrientation<TColor, TPacked>(Image<TColor, TPacked> source)
where TColor : IPackedVector<TPacked>
where TPacked : struct
@ -81,4 +86,4 @@ namespace ImageProcessorCore
return orientation;
}
}
}
}

18
src/ImageProcessorCore/Samplers/Options/ResizeHelper.cs

@ -17,7 +17,8 @@ namespace ImageProcessorCore
/// <summary>
/// Calculates the target location and bounds to perform the resize operation against.
/// </summary>
/// <typeparam name="TColor">The type of pixels contained within the image.</typeparam>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The source image.</param>
/// <param name="options">The resize options.</param>
/// <returns>
@ -49,7 +50,8 @@ namespace ImageProcessorCore
/// <summary>
/// Calculates the target rectangle for crop mode.
/// </summary>
/// <typeparam name="TColor">The type of pixels contained within the image.</typeparam>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The source image.</param>
/// <param name="options">The resize options.</param>
/// <returns>
@ -169,7 +171,8 @@ namespace ImageProcessorCore
/// <summary>
/// Calculates the target rectangle for pad mode.
/// </summary>
/// <typeparam name="TColor">The type of pixels contained within the image.</typeparam>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The source image.</param>
/// <param name="options">The resize options.</param>
/// <returns>
@ -251,7 +254,8 @@ namespace ImageProcessorCore
/// <summary>
/// Calculates the target rectangle for box pad mode.
/// </summary>
/// <typeparam name="TColor">The type of pixels contained within the image.</typeparam>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The source image.</param>
/// <param name="options">The resize options.</param>
/// <returns>
@ -339,7 +343,8 @@ namespace ImageProcessorCore
/// <summary>
/// Calculates the target rectangle for max mode.
/// </summary>
/// <typeparam name="TColor">The type of pixels contained within the image.</typeparam>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The source image.</param>
/// <param name="options">The resize options.</param>
/// <returns>
@ -381,7 +386,8 @@ namespace ImageProcessorCore
/// <summary>
/// Calculates the target rectangle for min mode.
/// </summary>
/// <typeparam name="TColor">The type of pixels contained within the image.</typeparam>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The source image.</param>
/// <param name="options">The resize options.</param>
/// <returns>

4
src/ImageProcessorCore/Samplers/Processors/EntropyCropProcessor.cs

@ -27,7 +27,7 @@ namespace ImageProcessorCore.Processors
/// Initializes a new instance of the <see cref="EntropyCropProcessor{TColor, TPacked}"/> class.
/// </summary>
/// <param name="threshold">The threshold to split the image. Must be between 0 and 1.</param>
/// <exception cref="ArgumentException">
/// <exception cref="System.ArgumentException">
/// <paramref name="threshold"/> is less than 0 or is greater than 1.
/// </exception>
public EntropyCropProcessor(float threshold)
@ -55,7 +55,7 @@ namespace ImageProcessorCore.Processors
// Search for the first white pixels
Rectangle rectangle = ImageMaths.GetFilteredBoundingRectangle(temp, 0);
// Reset the targeTColor pixel to the correct size.
// Reset the target pixel to the correct size.
target.SetPixels(rectangle.Width, rectangle.Height, new TColor[rectangle.Width * rectangle.Height]);
this.cropRectangle = rectangle;
}

2
src/ImageProcessorCore/Samplers/Processors/ImageSampler.cs

@ -16,4 +16,4 @@ namespace ImageProcessorCore.Processors
where TPacked : struct
{
}
}
}

16
src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs

@ -2,6 +2,9 @@
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
using System;
namespace ImageProcessorCore.Processors
{
using System.Numerics;
@ -34,7 +37,9 @@ namespace ImageProcessorCore.Processors
/// <inheritdoc/>
protected override void OnApply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle)
{
if (Angle == 0 || Angle == 90 || Angle == 180 || Angle == 270)
const float Epsilon = .0001F;
if (Math.Abs(Angle) < Epsilon || Math.Abs(Angle - 90) < Epsilon || Math.Abs(Angle - 180) < Epsilon || Math.Abs(Angle - 270) < Epsilon)
{
return;
}
@ -89,25 +94,26 @@ namespace ImageProcessorCore.Processors
/// <returns></returns>
private bool OptimizedApply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source)
{
if (Angle == 0)
const float Epsilon = .0001F;
if (Math.Abs(Angle) < Epsilon)
{
target.ClonePixels(target.Width, target.Height, source.Pixels);
return true;
}
if (Angle == 90)
if (Math.Abs(Angle - 90) < Epsilon)
{
this.Rotate90(target, source);
return true;
}
if (Angle == 180)
if (Math.Abs(Angle - 180) < Epsilon)
{
this.Rotate180(target, source);
return true;
}
if (Angle == 270)
if (Math.Abs(Angle - 270) < Epsilon)
{
this.Rotate270(target, source);
return true;

2
src/ImageProcessorCore/Samplers/Resamplers/NearestNeighborResampler.cs

@ -7,7 +7,7 @@ namespace ImageProcessorCore
{
/// <summary>
/// The function implements the nearest neighbour algorithm. This uses an unscaled filter
/// which will select the closesTColor pixel to the new pixels position.
/// which will select the closest pixel to the new pixels position.
/// </summary>
public class NearestNeighborResampler : IResampler
{

4
src/ImageProcessorCore/Samplers/RotateFlip.cs

@ -25,9 +25,7 @@ namespace ImageProcessorCore
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return source
.Rotate(rotateType, progressHandler)
.Flip(flipType, progressHandler);
return source.Rotate(rotateType, progressHandler).Flip(flipType, progressHandler);
}
}
}

Loading…
Cancel
Save