diff --git a/src/ImageProcessorCore/Bootstrapper.cs b/src/ImageProcessorCore/Bootstrapper.cs
index 36e53ce51..2076fab19 100644
--- a/src/ImageProcessorCore/Bootstrapper.cs
+++ b/src/ImageProcessorCore/Bootstrapper.cs
@@ -70,16 +70,16 @@ namespace ImageProcessorCore
///
/// Gets an instance of the correct for the packed vector.
///
- /// The type of pixel data.
+ /// The type of pixel data.
/// The image
/// The
- public IPixelAccessor GetPixelAccessor(IImageBase image)
- where TPackedVector : IPackedVector, new()
+ public IPixelAccessor GetPixelAccessor(IImageBase image)
+ where T : IPackedVector, new()
{
- Type packed = typeof(TPackedVector);
+ Type packed = typeof(T);
if (this.pixelAccessors.ContainsKey(packed))
{
- return (IPixelAccessor)this.pixelAccessors[packed].Invoke(image);
+ return (IPixelAccessor)this.pixelAccessors[packed].Invoke(image);
}
throw new NotSupportedException($"PixelAccessor cannot be loaded for {packed}:");
diff --git a/src/ImageProcessorCore/Formats/Bmp/BmpDecoder.cs b/src/ImageProcessorCore/Formats/Bmp/BmpDecoder.cs
index 4872ba89d..5565fd690 100644
--- a/src/ImageProcessorCore/Formats/Bmp/BmpDecoder.cs
+++ b/src/ImageProcessorCore/Formats/Bmp/BmpDecoder.cs
@@ -70,12 +70,12 @@ namespace ImageProcessorCore.Formats
}
///
- /// Decodes the image from the specified stream to the .
+ /// Decodes the image from the specified stream to the .
///
- /// The to decode to.
+ /// The to decode to.
/// The containing image data.
- public void Decode(Image image, Stream stream)
- where TPackedVector : IPackedVector, new()
+ public void Decode(Image image, Stream stream)
+ where T : IPackedVector, new()
{
new BmpDecoderCore().Decode(image, stream);
}
diff --git a/src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs b/src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs
index 4a36a07e3..56e2d2e2a 100644
--- a/src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs
+++ b/src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs
@@ -49,7 +49,7 @@ namespace ImageProcessorCore.Formats
/// Decodes the image from the specified this._stream and sets
/// the data to image.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The image, where the data should be set to.
/// Cannot be null (Nothing in Visual Basic).
/// The this._stream, where the image should be
@@ -59,8 +59,8 @@ namespace ImageProcessorCore.Formats
/// - or -
/// is null.
///
- public void Decode(Image image, Stream stream)
- where TPackedVector : IPackedVector, new()
+ public void Decode(Image image, Stream stream)
+ where T : IPackedVector, new()
{
this.currentStream = stream;
@@ -119,7 +119,7 @@ namespace ImageProcessorCore.Formats
+ $"bigger then the max allowed size '{image.MaxWidth}x{image.MaxHeight}'");
}
- TPackedVector[] imageData = new TPackedVector[this.infoHeader.Width * this.infoHeader.Height];
+ T[] imageData = new T[this.infoHeader.Width * this.infoHeader.Height];
switch (this.infoHeader.Compression)
{
@@ -192,15 +192,15 @@ namespace ImageProcessorCore.Formats
///
/// Reads the color palette from the stream.
///
- /// The type of pixels contained within the image.
- /// The image data to assign the palette to.
+ /// The type of pixels contained within the image.
+ /// The image data to assign the palette to.
/// The containing the colors.
/// The width of the bitmap.
/// The height of the bitmap.
/// The number of bits per pixel.
/// Whether the bitmap is inverted.
- private void ReadRgbPalette(TPackedVector[] imageData, byte[] colors, int width, int height, int bits, bool inverted)
- where TPackedVector : IPackedVector, new()
+ private void ReadRgbPalette(T[] imageData, byte[] colors, int width, int height, int bits, bool inverted)
+ where T : IPackedVector, new()
{
// Pixels per byte (bits per pixel)
int ppb = 8 / bits;
@@ -243,7 +243,7 @@ namespace ImageProcessorCore.Formats
int arrayOffset = (row * width) + (colOffset + shift);
// Stored in b-> g-> r-> a order.
- TPackedVector packed = new TPackedVector();
+ T packed = new T();
packed.PackBytes(colors[colorIndex], colors[colorIndex + 1], colors[colorIndex + 2], 255);
imageData[arrayOffset] = packed;
}
@@ -254,13 +254,13 @@ namespace ImageProcessorCore.Formats
///
/// Reads the 16 bit color palette from the stream
///
- /// The type of pixels contained within the image.
- /// The image data to assign the palette to.
+ /// The type of pixels contained within the image.
+ /// The image data to assign the palette to.
/// The width of the bitmap.
/// The height of the bitmap.
/// Whether the bitmap is inverted.
- private void ReadRgb16(TPackedVector[] imageData, int width, int height, bool inverted)
- where TPackedVector : IPackedVector, new()
+ private void ReadRgb16(T[] imageData, int width, int height, bool inverted)
+ where T : IPackedVector, new()
{
// We divide here as we will store the colors in our floating point format.
const int ScaleR = 8; // 256/32
@@ -292,7 +292,7 @@ namespace ImageProcessorCore.Formats
int arrayOffset = ((row * width) + x);
// Stored in b-> g-> r-> a order.
- TPackedVector packed = new TPackedVector();
+ T packed = new T();
packed.PackBytes(b, g, r, 255);
imageData[arrayOffset] = packed;
}
@@ -302,13 +302,13 @@ namespace ImageProcessorCore.Formats
///
/// Reads the 24 bit color palette from the stream
///
- /// The type of pixels contained within the image.
- /// The image data to assign the palette to.
+ /// The type of pixels contained within the image.
+ /// The image data to assign the palette to.
/// The width of the bitmap.
/// The height of the bitmap.
/// Whether the bitmap is inverted.
- private void ReadRgb24(TPackedVector[] imageData, int width, int height, bool inverted)
- where TPackedVector : IPackedVector, new()
+ private void ReadRgb24(T[] imageData, int width, int height, bool inverted)
+ where T : IPackedVector, new()
{
int alignment;
byte[] data = this.GetImageArray(width, height, 3, out alignment);
@@ -330,7 +330,7 @@ namespace ImageProcessorCore.Formats
// We divide by 255 as we will store the colors in our floating point format.
// Stored in b-> g-> r-> a order.
- TPackedVector packed = new TPackedVector();
+ T packed = new T();
packed.PackBytes(data[offset], data[offset + 1], data[offset + 2], 255);
imageData[arrayOffset] = packed;
}
@@ -340,13 +340,13 @@ namespace ImageProcessorCore.Formats
///
/// Reads the 32 bit color palette from the stream
///
- /// The type of pixels contained within the image.
- /// The image data to assign the palette to.
+ /// The type of pixels contained within the image.
+ /// The image data to assign the palette to.
/// The width of the bitmap.
/// The height of the bitmap.
/// Whether the bitmap is inverted.
- private void ReadRgb32(TPackedVector[] imageData, int width, int height, bool inverted)
- where TPackedVector : IPackedVector, new()
+ private void ReadRgb32(T[] imageData, int width, int height, bool inverted)
+ where T : IPackedVector, new()
{
int alignment;
byte[] data = this.GetImageArray(width, height, 4, out alignment);
@@ -367,7 +367,7 @@ namespace ImageProcessorCore.Formats
int arrayOffset = ((row * width) + x);
// Stored in b-> g-> r-> a order.
- TPackedVector packed = new TPackedVector();
+ T packed = new T();
packed.PackBytes(data[offset], data[offset + 1], data[offset + 2], data[offset + 3]);
imageData[arrayOffset] = packed;
}
diff --git a/src/ImageProcessorCore/Formats/Bmp/BmpEncoder.cs b/src/ImageProcessorCore/Formats/Bmp/BmpEncoder.cs
index bb413cc38..f58f6b85f 100644
--- a/src/ImageProcessorCore/Formats/Bmp/BmpEncoder.cs
+++ b/src/ImageProcessorCore/Formats/Bmp/BmpEncoder.cs
@@ -43,8 +43,8 @@ namespace ImageProcessorCore.Formats
}
///
- public void Encode(ImageBase image, Stream stream)
- where TPackedVector : IPackedVector, new()
+ public void Encode(ImageBase image, Stream stream)
+ where T : IPackedVector, new()
{
BmpEncoderCore encoder = new BmpEncoderCore();
encoder.Encode(image, stream, this.BitsPerPixel);
diff --git a/src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs b/src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs
index fae92c0f1..1df95592a 100644
--- a/src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs
+++ b/src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs
@@ -22,14 +22,14 @@ namespace ImageProcessorCore.Formats
private BmpBitsPerPixel bmpBitsPerPixel;
///
- /// Encodes the image to the specified stream from the .
+ /// Encodes the image to the specified stream from the .
///
- /// The type of pixels contained within the image.
- /// The to encode from.
+ /// The type of pixels contained within the image.
+ /// The to encode from.
/// The to encode the image data to.
/// The
- public void Encode(ImageBase image, Stream stream, BmpBitsPerPixel bitsPerPixel)
- where TPackedVector : IPackedVector, new()
+ public void Encode(ImageBase image, Stream stream, BmpBitsPerPixel bitsPerPixel)
+ where T : IPackedVector, new()
{
Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream));
@@ -120,15 +120,15 @@ namespace ImageProcessorCore.Formats
///
/// Writes the pixel data to the binary stream.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
///
/// The containing the stream to write to.
///
///
- /// The containing pixel data.
+ /// The containing pixel data.
///
- private void WriteImage(EndianBinaryWriter writer, ImageBase image)
- where TPackedVector : IPackedVector, new()
+ private void WriteImage(EndianBinaryWriter writer, ImageBase image)
+ where T : IPackedVector, new()
{
// TODO: Add more compression formats.
int amount = (image.Width * (int)this.bmpBitsPerPixel) % 4;
@@ -137,7 +137,7 @@ namespace ImageProcessorCore.Formats
amount = 4 - amount;
}
- using (IPixelAccessor pixels = image.Lock())
+ using (IPixelAccessor pixels = image.Lock())
{
switch (this.bmpBitsPerPixel)
{
@@ -155,12 +155,12 @@ namespace ImageProcessorCore.Formats
///
/// Writes the 32bit color palette to the stream.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The containing the stream to write to.
/// The containing pixel data.
/// The amount to pad each row by.
- private void Write32bit(EndianBinaryWriter writer, IPixelAccessor pixels, int amount)
- where TPackedVector : IPackedVector, new()
+ private void Write32bit(EndianBinaryWriter writer, IPixelAccessor pixels, int amount)
+ where T : IPackedVector, new()
{
for (int y = pixels.Height - 1; y >= 0; y--)
{
@@ -185,8 +185,8 @@ namespace ImageProcessorCore.Formats
/// The containing the stream to write to.
/// The containing pixel data.
/// The amount to pad each row by.
- private void Write24bit(EndianBinaryWriter writer, IPixelAccessor pixels, int amount)
- where TPackedVector : IPackedVector, new()
+ private void Write24bit(EndianBinaryWriter writer, IPixelAccessor pixels, int amount)
+ where T : IPackedVector, new()
{
for (int y = pixels.Height - 1; y >= 0; y--)
{
diff --git a/src/ImageProcessorCore/Formats/IImageDecoder.cs b/src/ImageProcessorCore/Formats/IImageDecoder.cs
index 59b4ddb2d..3c5676bac 100644
--- a/src/ImageProcessorCore/Formats/IImageDecoder.cs
+++ b/src/ImageProcessorCore/Formats/IImageDecoder.cs
@@ -39,12 +39,12 @@ namespace ImageProcessorCore.Formats
bool IsSupportedFileFormat(byte[] header);
///
- /// Decodes the image from the specified stream to the .
+ /// Decodes the image from the specified stream to the .
///
- /// The type of pixels contained within the image.
- /// The to decode to.
+ /// The type of pixels contained within the image.
+ /// The to decode to.
/// The containing image data.
- void Decode(Image image, Stream stream)
- where TPackedVector : IPackedVector, new();
+ void Decode(Image image, Stream stream)
+ where T : IPackedVector, new();
}
}
diff --git a/src/ImageProcessorCore/Formats/IImageEncoder.cs b/src/ImageProcessorCore/Formats/IImageEncoder.cs
index 32b6f9901..6e83c11ae 100644
--- a/src/ImageProcessorCore/Formats/IImageEncoder.cs
+++ b/src/ImageProcessorCore/Formats/IImageEncoder.cs
@@ -43,12 +43,12 @@ 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 type of pixels contained within the image.
- /// The to encode from.
+ /// The type of pixels contained within the image.
+ /// The to encode from.
/// The to encode the image data to.
- void Encode(ImageBase image, Stream stream)
- where TPackedVector : IPackedVector, new();
+ void Encode(ImageBase image, Stream stream)
+ where T : IPackedVector, new();
}
}
diff --git a/src/ImageProcessorCore/IImageBase.cs b/src/ImageProcessorCore/IImageBase.cs
index 5a61f7670..4b78df66c 100644
--- a/src/ImageProcessorCore/IImageBase.cs
+++ b/src/ImageProcessorCore/IImageBase.cs
@@ -2,13 +2,13 @@
namespace ImageProcessorCore
{
- public interface IImageBase : IImageBase
- where TPackedVector : IPackedVector, new()
+ public interface IImageBase : IImageBase
+ where T : IPackedVector, new()
{
- TPackedVector[] Pixels { get; }
- void ClonePixels(int width, int height, TPackedVector[] pixels);
- IPixelAccessor Lock();
- void SetPixels(int width, int height, TPackedVector[] pixels);
+ T[] Pixels { get; }
+ void ClonePixels(int width, int height, T[] pixels);
+ IPixelAccessor Lock();
+ void SetPixels(int width, int height, T[] pixels);
}
public interface IImageBase
diff --git a/src/ImageProcessorCore/IImageFrame.cs b/src/ImageProcessorCore/IImageFrame.cs
index a3c82d932..fc92b9306 100644
--- a/src/ImageProcessorCore/IImageFrame.cs
+++ b/src/ImageProcessorCore/IImageFrame.cs
@@ -1,7 +1,7 @@
namespace ImageProcessorCore
{
- public interface IImageFrame : IImageBase
- where TPacked : IPackedVector, new()
+ public interface IImageFrame : IImageBase
+ where T : IPackedVector, new()
{
}
}
diff --git a/src/ImageProcessorCore/IImageProcessor.cs b/src/ImageProcessorCore/IImageProcessor.cs
index 153dd0a84..76bc9851c 100644
--- a/src/ImageProcessorCore/IImageProcessor.cs
+++ b/src/ImageProcessorCore/IImageProcessor.cs
@@ -27,9 +27,9 @@ namespace ImageProcessorCore.Processors
event ProgressEventHandler OnProgress;
///
- /// Applies the process to the specified portion of the specified .
+ /// Applies the process to the specified portion of the specified .
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// Target image to apply the process to.
/// The source image. Cannot be null.
///
@@ -45,14 +45,14 @@ namespace ImageProcessorCore.Processors
///
/// doesnt fit the dimension of the image.
///
- void Apply(ImageBase target, ImageBase source, Rectangle sourceRectangle)
- where TPackedVector : IPackedVector, new();
+ void Apply(ImageBase target, ImageBase source, Rectangle sourceRectangle)
+ where T : IPackedVector, new();
///
- /// Applies the process to the specified portion of the specified at the specified
+ /// Applies the process to the specified portion of the specified at the specified
/// location and with the specified size.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// Target image to apply the process to.
/// The source image. Cannot be null.
/// The target width.
@@ -68,7 +68,7 @@ namespace ImageProcessorCore.Processors
/// The method keeps the source image unchanged and returns the
/// the result of image process as new image.
///
- void Apply(ImageBase target, ImageBase source, int width, int height, Rectangle targetRectangle, Rectangle sourceRectangle)
- where TPackedVector : IPackedVector, new();
+ void Apply(ImageBase target, ImageBase source, int width, int height, Rectangle targetRectangle, Rectangle sourceRectangle)
+ where T : IPackedVector, new();
}
}
diff --git a/src/ImageProcessorCore/Image.cs b/src/ImageProcessorCore/Image.cs
index a672f6a25..35eaff243 100644
--- a/src/ImageProcessorCore/Image.cs
+++ b/src/ImageProcessorCore/Image.cs
@@ -17,11 +17,11 @@ namespace ImageProcessorCore
///
/// Encapsulates an image, which consists of the pixel data for a graphics image and its attributes.
///
- ///
+ ///
/// The packed vector containing pixel information.
///
- public class Image : ImageBase
- where TPackedVector : IPackedVector, new()
+ public class Image : ImageBase
+ where T : IPackedVector, new()
{
///
/// The default horizontal resolution value (dots per inch) in x direction.
@@ -36,7 +36,7 @@ namespace ImageProcessorCore
public const double DefaultVerticalResolution = 96;
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public Image()
{
@@ -44,7 +44,7 @@ namespace ImageProcessorCore
}
///
- /// Initializes a new instance of the class
+ /// Initializes a new instance of the class
/// with the height and the width of the image.
///
/// The width of the image in pixels.
@@ -57,7 +57,7 @@ namespace ImageProcessorCore
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
///
/// The stream containing image information.
@@ -70,18 +70,18 @@ namespace ImageProcessorCore
}
///
- /// Initializes a new instance of the class
+ /// Initializes a new instance of the class
/// by making a copy from another image.
///
/// The other image, where the clone should be made from.
/// is null.
- public Image(Image other)
+ public Image(Image other)
{
- foreach (ImageFrame frame in other.Frames)
+ foreach (ImageFrame frame in other.Frames)
{
if (frame != null)
{
- this.Frames.Add(new ImageFrame(frame));
+ this.Frames.Add(new ImageFrame(frame));
}
}
@@ -170,7 +170,7 @@ namespace ImageProcessorCore
/// Gets the other frames for the animation.
///
/// The list of frame images.
- public IList> Frames { get; } = new List>();
+ public IList> Frames { get; } = new List>();
///
/// Gets the list of properties for storing meta information about this image.
@@ -184,9 +184,9 @@ namespace ImageProcessorCore
public IImageFormat CurrentImageFormat { get; internal set; }
///
- public override IPixelAccessor Lock()
+ public override IPixelAccessor Lock()
{
- return Bootstrapper.Instance.GetPixelAccessor(this);
+ return Bootstrapper.Instance.GetPixelAccessor(this);
}
///
diff --git a/src/ImageProcessorCore/ImageBase.cs b/src/ImageProcessorCore/ImageBase.cs
index 0c0bb6fac..357f49001 100644
--- a/src/ImageProcessorCore/ImageBase.cs
+++ b/src/ImageProcessorCore/ImageBase.cs
@@ -11,21 +11,21 @@ namespace ImageProcessorCore
/// The base class of all images. Encapsulates the basic properties and methods required to manipulate images
/// in different pixel formats.
///
- ///
+ ///
/// The packed vector pixels format.
///
- public abstract class ImageBase : IImageBase
- where TPackedVector : IPackedVector, new()
+ public abstract class ImageBase : IImageBase
+ where T : IPackedVector, new()
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
protected ImageBase()
{
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The width of the image in pixels.
/// The height of the image in pixels.
@@ -39,19 +39,19 @@ namespace ImageProcessorCore
this.Width = width;
this.Height = height;
- this.Pixels = new TPackedVector[width * height];
+ this.Pixels = new T[width * height];
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
///
- /// The other to create this instance from.
+ /// The other to create this instance from.
///
///
- /// Thrown if the given is null.
+ /// Thrown if the given is null.
///
- protected ImageBase(ImageBase other)
+ protected ImageBase(ImageBase other)
{
Guard.NotNull(other, nameof(other), "Other image cannot be null.");
@@ -61,7 +61,7 @@ namespace ImageProcessorCore
this.FrameDelay = other.FrameDelay;
// Copy the pixels.
- this.Pixels = new TPackedVector[this.Width * this.Height];
+ this.Pixels = new T[this.Width * this.Height];
Array.Copy(other.Pixels, this.Pixels, other.Pixels.Length);
}
@@ -78,7 +78,7 @@ namespace ImageProcessorCore
///
/// Gets the pixels as an array of the given packed pixel format.
///
- public TPackedVector[] Pixels { get; private set; }
+ public T[] Pixels { get; private set; }
///
/// Gets the width in pixels.
@@ -127,7 +127,7 @@ namespace ImageProcessorCore
///
/// Thrown if the length is not equal to Width * Height.
///
- public void SetPixels(int width, int height, TPackedVector[] pixels)
+ public void SetPixels(int width, int height, T[] pixels)
{
if (width <= 0)
{
@@ -164,7 +164,7 @@ namespace ImageProcessorCore
///
/// Thrown if the length is not equal to Width * Height.
///
- public void ClonePixels(int width, int height, TPackedVector[] pixels)
+ public void ClonePixels(int width, int height, T[] pixels)
{
if (width <= 0)
{
@@ -185,7 +185,7 @@ namespace ImageProcessorCore
this.Height = height;
// Copy the pixels.
- this.Pixels = new TPackedVector[pixels.Length];
+ this.Pixels = new T[pixels.Length];
Array.Copy(pixels, this.Pixels, pixels.Length);
}
@@ -196,6 +196,6 @@ namespace ImageProcessorCore
///
///
/// The
- public abstract IPixelAccessor Lock();
+ public abstract IPixelAccessor Lock();
}
}
diff --git a/src/ImageProcessorCore/ImageExtensions.cs b/src/ImageProcessorCore/ImageExtensions.cs
index 526ec8d55..c30607ce9 100644
--- a/src/ImageProcessorCore/ImageExtensions.cs
+++ b/src/ImageProcessorCore/ImageExtensions.cs
@@ -12,7 +12,7 @@ namespace ImageProcessorCore
using Processors;
///
- /// Extension methods for the type.
+ /// Extension methods for the type.
///
public static partial class ImageExtensions
{
@@ -57,12 +57,12 @@ namespace ImageProcessorCore
/// Applies the collection of processors to the image.
/// This method does not resize the target image.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The image this method extends.
/// The processor to apply to the image.
- /// The .
- public static Image Process(this Image source, IImageProcessor processor)
- where TPackedVector : IPackedVector, new()
+ /// The .
+ public static Image Process(this Image source, IImageProcessor processor)
+ where T : IPackedVector, new()
{
return Process(source, source.Bounds, processor);
}
@@ -71,15 +71,15 @@ namespace ImageProcessorCore
/// Applies the collection of processors to the image.
/// This method does not resize the target image.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The image this method extends.
///
/// The structure that specifies the portion of the image object to draw.
///
/// The processors to apply to the image.
- /// The .
- public static Image Process(this Image source, Rectangle sourceRectangle, IImageProcessor processor)
- where TPackedVector : IPackedVector, new()
+ /// The .
+ public static Image Process(this Image source, Rectangle sourceRectangle, IImageProcessor processor)
+ where T : IPackedVector, new()
{
return PerformAction(source, true, (sourceImage, targetImage) => processor.Apply(targetImage, sourceImage, sourceRectangle));
}
@@ -90,14 +90,14 @@ namespace ImageProcessorCore
/// This method is not chainable.
///
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The source image. Cannot be null.
/// The target image width.
/// The target image height.
/// The processor to apply to the image.
- /// The .
- public static Image Process(this Image source, int width, int height, IImageSampler sampler)
- where TPackedVector : IPackedVector, new()
+ /// The .
+ public static Image Process(this Image source, int width, int height, IImageSampler sampler)
+ where T : IPackedVector, new()
{
return Process(source, width, height, source.Bounds, default(Rectangle), sampler);
}
@@ -108,7 +108,7 @@ namespace ImageProcessorCore
/// This method does will resize the target image if the source and target rectangles are different.
///
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The source image. Cannot be null.
/// The target image width.
/// The target image height.
@@ -120,9 +120,9 @@ namespace ImageProcessorCore
/// The image is scaled to fit the rectangle.
///
/// The processor to apply to the image.
- /// The .
- public static Image Process(this Image source, int width, int height, Rectangle sourceRectangle, Rectangle targetRectangle, IImageSampler sampler)
- where TPackedVector : IPackedVector, new()
+ /// The .
+ public static Image Process(this Image source, int width, int height, Rectangle sourceRectangle, Rectangle targetRectangle, IImageSampler sampler)
+ where T : IPackedVector, new()
{
return PerformAction(source, false, (sourceImage, targetImage) => sampler.Apply(targetImage, sourceImage, width, height, targetRectangle, sourceRectangle));
}
@@ -130,17 +130,17 @@ namespace ImageProcessorCore
///
/// Performs the given action on the source image.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The image to perform the action against.
/// Whether to clone the image.
/// The to perform against the image.
- /// The .
- private static Image PerformAction(Image source, bool clone, Action, ImageBase> action)
- where TPackedVector : IPackedVector, new()
+ /// The .
+ private static Image PerformAction(Image source, bool clone, Action, ImageBase> action)
+ where T : IPackedVector, new()
{
- Image transformedImage = clone
- ? new Image(source)
- : new Image
+ Image transformedImage = clone
+ ? new Image(source)
+ : new Image
{
// Several properties require copying
// TODO: Check why we need to set these?
@@ -154,10 +154,10 @@ namespace ImageProcessorCore
for (int i = 0; i < source.Frames.Count; i++)
{
- ImageFrame sourceFrame = source.Frames[i];
- ImageFrame tranformedFrame = clone
- ? new ImageFrame(sourceFrame)
- : new ImageFrame { FrameDelay = sourceFrame.FrameDelay };
+ ImageFrame sourceFrame = source.Frames[i];
+ ImageFrame tranformedFrame = clone
+ ? new ImageFrame(sourceFrame)
+ : new ImageFrame { FrameDelay = sourceFrame.FrameDelay };
action(sourceFrame, tranformedFrame);
diff --git a/src/ImageProcessorCore/ImageFrame.cs b/src/ImageProcessorCore/ImageFrame.cs
index 75d755f5f..790591b18 100644
--- a/src/ImageProcessorCore/ImageFrame.cs
+++ b/src/ImageProcessorCore/ImageFrame.cs
@@ -8,34 +8,34 @@ namespace ImageProcessorCore
///
/// Represents a single frame in a animation.
///
- ///
+ ///
/// The packed vector containing pixel information.
///
- public class ImageFrame : ImageBase
- where TPackedVector : IPackedVector, new()
+ public class ImageFrame : ImageBase
+ where T : IPackedVector, new()
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public ImageFrame()
{
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
///
/// The frame to create the frame from.
///
- public ImageFrame(ImageFrame frame)
+ public ImageFrame(ImageFrame frame)
: base(frame)
{
}
///
- public override IPixelAccessor Lock()
+ public override IPixelAccessor Lock()
{
- return Bootstrapper.Instance.GetPixelAccessor(this);
+ return Bootstrapper.Instance.GetPixelAccessor(this);
}
}
}
diff --git a/src/ImageProcessorCore/ImageProcessor.cs b/src/ImageProcessorCore/ImageProcessor.cs
index 0206e667e..380e5c634 100644
--- a/src/ImageProcessorCore/ImageProcessor.cs
+++ b/src/ImageProcessorCore/ImageProcessor.cs
@@ -27,8 +27,8 @@ namespace ImageProcessorCore.Processors
private int totalRows;
///
- public void Apply(ImageBase target, ImageBase source, Rectangle sourceRectangle)
- where TPackedVector : IPackedVector, new()
+ public void Apply(ImageBase target, ImageBase source, Rectangle sourceRectangle)
+ where T : IPackedVector, new()
{
try
{
@@ -49,12 +49,12 @@ namespace ImageProcessorCore.Processors
}
///
- public void Apply(ImageBase target, ImageBase source, int width, int height, Rectangle targetRectangle = default(Rectangle), Rectangle sourceRectangle = default(Rectangle))
- where TPackedVector : IPackedVector, new()
+ public void Apply(ImageBase target, ImageBase source, int width, int height, Rectangle targetRectangle = default(Rectangle), Rectangle sourceRectangle = default(Rectangle))
+ where T : IPackedVector, new()
{
try
{
- TPackedVector[] pixels = new TPackedVector[width * height];
+ T[] pixels = new T[width * height];
target.SetPixels(width, height, pixels);
// Ensure we always have bounds.
@@ -95,16 +95,16 @@ namespace ImageProcessorCore.Processors
///
/// The structure that specifies the portion of the image object to draw.
///
- protected virtual void OnApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle)
- where TPackedVector : IPackedVector, new()
+ protected virtual void OnApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle)
+ where T : IPackedVector, new()
{
}
///
- /// Applies the process to the specified portion of the specified at the specified location
+ /// Applies the process to the specified portion of the specified at the specified location
/// and with the specified size.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// Target image to apply the process to.
/// The source image. Cannot be null.
///
@@ -120,13 +120,13 @@ namespace ImageProcessorCore.Processors
/// The method keeps the source image unchanged and returns the
/// the result of image process as new image.
///
- protected abstract void Apply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
- where TPackedVector : IPackedVector, new();
+ protected abstract void Apply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
+ where T : IPackedVector, new();
///
/// This method is called after the process is applied to prepare the processor.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// Target image to apply the process to.
/// The source image. Cannot be null.
///
@@ -136,8 +136,8 @@ namespace ImageProcessorCore.Processors
///
/// The structure that specifies the portion of the image object to draw.
///
- protected virtual void AfterApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle)
- where TPackedVector : IPackedVector, new()
+ protected virtual void AfterApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle)
+ where T : IPackedVector, new()
{
}
diff --git a/src/ImageProcessorCore/PackedVector/IPackedVector.cs b/src/ImageProcessorCore/PackedVector/IPackedVector.cs
index 02e10cc3a..7022e4d9d 100644
--- a/src/ImageProcessorCore/PackedVector/IPackedVector.cs
+++ b/src/ImageProcessorCore/PackedVector/IPackedVector.cs
@@ -11,17 +11,17 @@ namespace ImageProcessorCore
/// An interface that converts packed vector types to and from values,
/// allowing multiple encodings to be manipulated in a generic way.
///
- ///
+ ///
/// The type of object representing the packed value.
///
- public interface IPackedVector : IPackedVector
- where TPacked : struct
+ public interface IPackedVector : IPackedVector
+ where T : struct
{
///
/// Gets or sets the packed representation of the value.
/// Typically packed in least to greatest significance order.
///
- TPacked PackedValue { get; set; }
+ T PackedValue { get; set; }
}
///
diff --git a/src/ImageProcessorCore/PixelAccessor/IPixelAccessor.cs b/src/ImageProcessorCore/PixelAccessor/IPixelAccessor.cs
index 7eac9fd03..f72616397 100644
--- a/src/ImageProcessorCore/PixelAccessor/IPixelAccessor.cs
+++ b/src/ImageProcessorCore/PixelAccessor/IPixelAccessor.cs
@@ -10,8 +10,8 @@ namespace ImageProcessorCore
///
/// Encapsulates properties to provides per-pixel access to an images pixels.
///
- public interface IPixelAccessor : IPixelAccessor
- where TPackedVector : IPackedVector, new()
+ public interface IPixelAccessor : IPixelAccessor
+ where T : IPackedVector, new()
{
///
/// Gets or sets the pixel at the specified position.
@@ -24,8 +24,8 @@ namespace ImageProcessorCore
/// The y-coordinate of the pixel. Must be greater
/// than zero and smaller than the width of the pixel.
///
- /// The at the specified position.
- TPackedVector this[int x, int y]
+ /// The at the specified position.
+ T this[int x, int y]
{
get;
set;
diff --git a/src/ImageProcessorCore/Samplers/Options/ResizeHelper.cs b/src/ImageProcessorCore/Samplers/Options/ResizeHelper.cs
index 2c3221ec6..0c806d5e8 100644
--- a/src/ImageProcessorCore/Samplers/Options/ResizeHelper.cs
+++ b/src/ImageProcessorCore/Samplers/Options/ResizeHelper.cs
@@ -17,14 +17,14 @@ namespace ImageProcessorCore
///
/// Calculates the target location and bounds to perform the resize operation against.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The source image.
/// The resize options.
///
/// The .
///
- public static Rectangle CalculateTargetLocationAndBounds(ImageBase source, ResizeOptions options)
- where TPackedVector : IPackedVector, new()
+ public static Rectangle CalculateTargetLocationAndBounds(ImageBase source, ResizeOptions options)
+ where T : IPackedVector, new()
{
switch (options.Mode)
{
@@ -48,14 +48,14 @@ namespace ImageProcessorCore
///
/// Calculates the target rectangle for crop mode.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The source image.
/// The resize options.
///
/// The .
///
- private static Rectangle CalculateCropRectangle(ImageBase source, ResizeOptions options)
- where TPackedVector : IPackedVector, new()
+ private static Rectangle CalculateCropRectangle(ImageBase source, ResizeOptions options)
+ where T : IPackedVector, new()
{
int width = options.Size.Width;
int height = options.Size.Height;
@@ -167,14 +167,14 @@ namespace ImageProcessorCore
///
/// Calculates the target rectangle for pad mode.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The source image.
/// The resize options.
///
/// The .
///
- private static Rectangle CalculatePadRectangle(ImageBase source, ResizeOptions options)
- where TPackedVector : IPackedVector, new()
+ private static Rectangle CalculatePadRectangle(ImageBase source, ResizeOptions options)
+ where T : IPackedVector, new()
{
int width = options.Size.Width;
int height = options.Size.Height;
@@ -248,14 +248,14 @@ namespace ImageProcessorCore
///
/// Calculates the target rectangle for box pad mode.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The source image.
/// The resize options.
///
/// The .
///
- private static Rectangle CalculateBoxPadRectangle(ImageBase source, ResizeOptions options)
- where TPackedVector : IPackedVector, new()
+ private static Rectangle CalculateBoxPadRectangle(ImageBase source, ResizeOptions options)
+ where T : IPackedVector, new()
{
int width = options.Size.Width;
int height = options.Size.Height;
@@ -335,14 +335,14 @@ namespace ImageProcessorCore
///
/// Calculates the target rectangle for max mode.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The source image.
/// The resize options.
///
/// The .
///
- private static Rectangle CalculateMaxRectangle(ImageBase source, ResizeOptions options)
- where TPackedVector : IPackedVector, new()
+ private static Rectangle CalculateMaxRectangle(ImageBase source, ResizeOptions options)
+ where T : IPackedVector, new()
{
int width = options.Size.Width;
int height = options.Size.Height;
@@ -376,14 +376,14 @@ namespace ImageProcessorCore
///
/// Calculates the target rectangle for min mode.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The source image.
/// The resize options.
///
/// The .
///
- private static Rectangle CalculateMinRectangle(ImageBase source, ResizeOptions options)
- where TPackedVector : IPackedVector, new()
+ private static Rectangle CalculateMinRectangle(ImageBase source, ResizeOptions options)
+ where T : IPackedVector, new()
{
int width = options.Size.Width;
int height = options.Size.Height;
diff --git a/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs
index 11b397d74..67d20a564 100644
--- a/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs
+++ b/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs
@@ -43,7 +43,7 @@ namespace ImageProcessorCore.Processors
protected Weights[] VerticalWeights { get; set; }
///
- protected override void OnApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle)
+ protected override void OnApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle)
{
if (!(this.Sampler is NearestNeighborResampler))
{
@@ -53,7 +53,7 @@ namespace ImageProcessorCore.Processors
}
///
- protected override void Apply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
+ protected override void Apply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
{
// Jump out, we'll deal with that later.
if (source.Bounds == target.Bounds && sourceRectangle == targetRectangle)
@@ -78,8 +78,8 @@ namespace ImageProcessorCore.Processors
float widthFactor = sourceRectangle.Width / (float)targetRectangle.Width;
float heightFactor = sourceRectangle.Height / (float)targetRectangle.Height;
- using (IPixelAccessor sourcePixels = source.Lock())
- using (IPixelAccessor targetPixels = target.Lock())
+ using (IPixelAccessor sourcePixels = source.Lock())
+ using (IPixelAccessor targetPixels = target.Lock())
{
Parallel.For(
startY,
@@ -114,10 +114,10 @@ namespace ImageProcessorCore.Processors
// A 2-pass 1D algorithm appears to be faster than splitting a 1-pass 2D algorithm
// First process the columns. Since we are not using multiple threads startY and endY
// are the upper and lower bounds of the source rectangle.
- Image firstPass = new Image(target.Width, source.Height);
- using (IPixelAccessor sourcePixels = source.Lock())
- using (IPixelAccessor firstPassPixels = firstPass.Lock())
- using (IPixelAccessor targetPixels = target.Lock())
+ Image firstPass = new Image(target.Width, source.Height);
+ using (IPixelAccessor sourcePixels = source.Lock())
+ using (IPixelAccessor firstPassPixels = firstPass.Lock())
+ using (IPixelAccessor targetPixels = target.Lock())
{
Parallel.For(
0,
@@ -163,7 +163,6 @@ namespace ImageProcessorCore.Processors
//Color sourceColor = compand
// ? Color.Expand(sourcePixels[originX, y])
// : sourcePixels[originX, y];
-
destination += sourceColor * xw.Value;
}
@@ -171,7 +170,7 @@ namespace ImageProcessorCore.Processors
//{
// destination = Color.Compress(destination);
//}
- TPackedVector packed = new TPackedVector();
+ T packed = new T();
packed.PackVector(destination);
firstPassPixels[x, y] = packed;
@@ -213,7 +212,7 @@ namespace ImageProcessorCore.Processors
// destination = Color.Compress(destination);
//}
- TPackedVector packed = new TPackedVector();
+ T packed = new T();
packed.PackVector(destination);
targetPixels[x, y] = packed;
@@ -227,7 +226,7 @@ namespace ImageProcessorCore.Processors
}
///
- protected override void AfterApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle)
+ protected override void AfterApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle)
{
// Copy the pixels over.
if (source.Bounds == target.Bounds && sourceRectangle == targetRectangle)
diff --git a/src/ImageProcessorCore/Samplers/Resize.cs b/src/ImageProcessorCore/Samplers/Resize.cs
index 3d81f41da..3dd0a9c96 100644
--- a/src/ImageProcessorCore/Samplers/Resize.cs
+++ b/src/ImageProcessorCore/Samplers/Resize.cs
@@ -15,14 +15,14 @@ namespace ImageProcessorCore
///
/// Resizes an image in accordance with the given .
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The image to resize.
/// The resize options.
/// A delegate which is called as progress is made processing the image.
- /// The
+ /// The
/// Passing zero for one of height or width within the resize options will automatically preserve the aspect ratio of the original image
- public static Image Resize(this Image source, ResizeOptions options, ProgressEventHandler progressHandler = null)
- where TPackedVector : IPackedVector, new()
+ public static Image Resize(this Image source, ResizeOptions options, ProgressEventHandler progressHandler = null)
+ where T : IPackedVector, new()
{
// Ensure size is populated across both dimensions.
if (options.Size.Width == 0 && options.Size.Height > 0)
@@ -43,15 +43,15 @@ namespace ImageProcessorCore
///
/// Resizes an image to the given width and height.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The image to resize.
/// The target image width.
/// The target image height.
/// A delegate which is called as progress is made processing the image.
- /// The
+ /// The
/// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image
- public static Image Resize(this Image source, int width, int height, ProgressEventHandler progressHandler = null)
- where TPackedVector : IPackedVector, new()
+ public static Image Resize(this Image source, int width, int height, ProgressEventHandler progressHandler = null)
+ where T : IPackedVector, new()
{
return Resize(source, width, height, new BicubicResampler(), false, progressHandler);
}
@@ -59,16 +59,16 @@ namespace ImageProcessorCore
///
/// Resizes an image to the given width and height.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The image to resize.
/// The target image width.
/// The target image height.
/// Whether to compress and expand the image color-space to gamma correct the image during processing.
/// A delegate which is called as progress is made processing the image.
- /// The
+ /// The
/// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image
- public static Image Resize(this Image source, int width, int height, bool compand, ProgressEventHandler progressHandler = null)
- where TPackedVector : IPackedVector, new()
+ public static Image Resize(this Image source, int width, int height, bool compand, ProgressEventHandler progressHandler = null)
+ where T : IPackedVector, new()
{
return Resize(source, width, height, new BicubicResampler(), compand, progressHandler);
}
@@ -76,17 +76,17 @@ namespace ImageProcessorCore
///
/// Resizes an image to the given width and height with the given sampler.
///
- /// The type of pixels contained within the image.
+ /// The type of pixels contained within the image.
/// The image to resize.
/// The target image width.
/// The target image height.
/// The to perform the resampling.
/// Whether to compress and expand the image color-space to gamma correct the image during processing.
/// A delegate which is called as progress is made processing the image.
- /// The
+ /// The
/// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image
- public static Image Resize(this Image source, int width, int height, IResampler sampler, bool compand, ProgressEventHandler progressHandler = null)
- where TPackedVector : IPackedVector, new()
+ public static Image