Browse Source

No need for second type param

Former-commit-id: 19180d2962371ebdbe77b1e08a1867b8630abf43
Former-commit-id: 84da094533206cb0c1a859a438fe6a937af9fa77
Former-commit-id: 3094f56fbf68569748a6b31f3874cf716ed673b6
af/merge-core
James Jackson-South 10 years ago
parent
commit
c11751e6c5
  1. 2
      src/ImageProcessorCore/Bootstrapper.cs
  2. 2
      src/ImageProcessorCore/Formats/Bmp/BmpDecoder.cs
  3. 10
      src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs
  4. 2
      src/ImageProcessorCore/Formats/Bmp/BmpEncoder.cs
  5. 8
      src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs
  6. 2
      src/ImageProcessorCore/Formats/IImageDecoder.cs
  7. 2
      src/ImageProcessorCore/Formats/IImageEncoder.cs
  8. 2
      src/ImageProcessorCore/Image/IImageBase.cs
  9. 2
      src/ImageProcessorCore/Image/IImageFrame.cs
  10. 4
      src/ImageProcessorCore/Image/IImageProcessor.cs
  11. 2
      src/ImageProcessorCore/Image/Image.cs
  12. 2
      src/ImageProcessorCore/Image/ImageBase.cs
  13. 10
      src/ImageProcessorCore/Image/ImageExtensions.cs
  14. 2
      src/ImageProcessorCore/Image/ImageFrame.cs
  15. 10
      src/ImageProcessorCore/ImageProcessor.cs
  16. 2
      src/ImageProcessorCore/PackedVector/Bgra32.cs
  17. 3
      src/ImageProcessorCore/PackedVector/IPackedVector.cs
  18. 9
      src/ImageProcessorCore/PixelAccessor/IPixelAccessor.cs
  19. 12
      src/ImageProcessorCore/Samplers/Options/ResizeHelper.cs
  20. 10
      src/ImageProcessorCore/Samplers/Resize.cs

2
src/ImageProcessorCore/Bootstrapper.cs

@ -74,7 +74,7 @@ namespace ImageProcessorCore
/// <param name="image">The image</param>
/// <returns>The <see cref="IPixelAccessor"/></returns>
public IPixelAccessor<T, TP> GetPixelAccessor<T, TP>(IImageBase image)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
Type packed = typeof(T);

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

@ -75,7 +75,7 @@ namespace ImageProcessorCore.Formats
/// <param name="image">The <see cref="ImageBase{T}"/> to decode to.</param>
/// <param name="stream">The <see cref="Stream"/> containing image data.</param>
public void Decode<T,TP>(Image<T,TP> image, Stream stream)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
new BmpDecoderCore().Decode(image, stream);

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

@ -60,7 +60,7 @@ namespace ImageProcessorCore.Formats
/// <para><paramref name="stream"/> is null.</para>
/// </exception>
public void Decode<T, TP>(Image<T, TP> image, Stream stream)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
this.currentStream = stream;
@ -195,7 +195,7 @@ namespace ImageProcessorCore.Formats
/// <param name="bits">The number of bits per pixel.</param>
/// <param name="inverted">Whether the bitmap is inverted.</param>
private void ReadRgbPalette<T, TP>(T[] imageData, byte[] colors, int width, int height, int bits, bool inverted)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
// Pixels per byte (bits per pixel)
@ -256,7 +256,7 @@ namespace ImageProcessorCore.Formats
/// <param name="height">The height of the bitmap.</param>
/// <param name="inverted">Whether the bitmap is inverted.</param>
private void ReadRgb16<T, TP>(T[] imageData, int width, int height, bool inverted)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
// We divide here as we will store the colors in our floating point format.
@ -305,7 +305,7 @@ namespace ImageProcessorCore.Formats
/// <param name="height">The height of the bitmap.</param>
/// <param name="inverted">Whether the bitmap is inverted.</param>
private void ReadRgb24<T, TP>(T[] imageData, int width, int height, bool inverted)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
int alignment;
@ -344,7 +344,7 @@ namespace ImageProcessorCore.Formats
/// <param name="height">The height of the bitmap.</param>
/// <param name="inverted">Whether the bitmap is inverted.</param>
private void ReadRgb32<T, TP>(T[] imageData, int width, int height, bool inverted)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
int alignment;

2
src/ImageProcessorCore/Formats/Bmp/BmpEncoder.cs

@ -44,7 +44,7 @@ namespace ImageProcessorCore.Formats
/// <inheritdoc/>
public void Encode<T,TP>(ImageBase<T,TP> image, Stream stream)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
BmpEncoderCore encoder = new BmpEncoderCore();

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

@ -29,7 +29,7 @@ namespace ImageProcessorCore.Formats
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
/// <param name="bitsPerPixel">The <see cref="BmpBitsPerPixel"/></param>
public void Encode<T,TP>(ImageBase<T,TP> image, Stream stream, BmpBitsPerPixel bitsPerPixel)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
Guard.NotNull(image, nameof(image));
@ -129,7 +129,7 @@ namespace ImageProcessorCore.Formats
/// The <see cref="ImageBase{T}"/> containing pixel data.
/// </param>
private void WriteImage<T,TP>(EndianBinaryWriter writer, ImageBase<T,TP> image)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
// TODO: Add more compression formats.
@ -162,7 +162,7 @@ namespace ImageProcessorCore.Formats
/// <param name="pixels">The <see cref="IPixelAccessor"/> containing pixel data.</param>
/// <param name="amount">The amount to pad each row by.</param>
private void Write32bit<T,TP>(EndianBinaryWriter writer, IPixelAccessor<T,TP> pixels, int amount)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
for (int y = pixels.Height - 1; y >= 0; y--)
@ -189,7 +189,7 @@ namespace ImageProcessorCore.Formats
/// <param name="pixels">The <see cref="IPixelAccessor"/> containing pixel data.</param>
/// <param name="amount">The amount to pad each row by.</param>
private void Write24bit<T,TP>(EndianBinaryWriter writer, IPixelAccessor<T,TP> pixels, int amount)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
for (int y = pixels.Height - 1; y >= 0; y--)

2
src/ImageProcessorCore/Formats/IImageDecoder.cs

@ -45,7 +45,7 @@ namespace ImageProcessorCore.Formats
/// <param name="image">The <see cref="ImageBase{T}"/> to decode to.</param>
/// <param name="stream">The <see cref="Stream"/> containing image data.</param>
void Decode<T, TP>(Image<T, TP> image, Stream stream)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct;
}
}

2
src/ImageProcessorCore/Formats/IImageEncoder.cs

@ -49,7 +49,7 @@ namespace ImageProcessorCore.Formats
/// <param name="image">The <see cref="ImageBase{T}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
void Encode<T, TP>(ImageBase<T, TP> image, Stream stream)
where T : IPackedVector<T, TP>,
where T : IPackedVector<TP>,
new() where TP : struct;
}
}

2
src/ImageProcessorCore/Image/IImageBase.cs

@ -13,7 +13,7 @@ namespace ImageProcessorCore
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
public interface IImageBase<T, TP> : IImageBase
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
/// <summary>

2
src/ImageProcessorCore/Image/IImageFrame.cs

@ -11,7 +11,7 @@ namespace ImageProcessorCore
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
public interface IImageFrame<T, TP> : IImageBase<T, TP>
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
}

4
src/ImageProcessorCore/Image/IImageProcessor.cs

@ -47,7 +47,7 @@ namespace ImageProcessorCore.Processors
/// <paramref name="sourceRectangle"/> doesnt fit the dimension of the image.
/// </exception>
void Apply<T, TP>(ImageBase<T, TP> target, ImageBase<T, TP> source, Rectangle sourceRectangle)
where T : IPackedVector<T, TP>,
where T : IPackedVector<TP>,
new() where TP : struct;
/// <summary>
@ -72,7 +72,7 @@ namespace ImageProcessorCore.Processors
/// the result of image process as new image.
/// </remarks>
void Apply<T, TP>(ImageBase<T, TP> target, ImageBase<T, TP> source, int width, int height, Rectangle targetRectangle, Rectangle sourceRectangle)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct;
}
}

2
src/ImageProcessorCore/Image/Image.cs

@ -20,7 +20,7 @@ namespace ImageProcessorCore
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
public class Image<T, TP> : ImageBase<T, TP>
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
/// <summary>

2
src/ImageProcessorCore/Image/ImageBase.cs

@ -14,7 +14,7 @@ namespace ImageProcessorCore
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
public abstract class ImageBase<T, TP> : IImageBase<T, TP>
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
/// <summary>

10
src/ImageProcessorCore/Image/ImageExtensions.cs

@ -63,7 +63,7 @@ namespace ImageProcessorCore
/// <param name="processor">The processor to apply to the image.</param>
/// <returns>The <see cref="Image{T, TP}"/>.</returns>
public static Image<T, TP> Process<T, TP>(this Image<T, TP> source, IImageProcessor processor)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
return Process(source, source.Bounds, processor);
@ -82,7 +82,7 @@ namespace ImageProcessorCore
/// <param name="processor">The processors to apply to the image.</param>
/// <returns>The <see cref="Image{T, TP}"/>.</returns>
public static Image<T, TP> Process<T, TP>(this Image<T, TP> source, Rectangle sourceRectangle, IImageProcessor processor)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
return PerformAction(source, true, (sourceImage, targetImage) => processor.Apply(targetImage, sourceImage, sourceRectangle));
@ -102,7 +102,7 @@ namespace ImageProcessorCore
/// <param name="sampler">The processor to apply to the image.</param>
/// <returns>The <see cref="Image{T, TP}"/>.</returns>
public static Image<T, TP> Process<T, TP>(this Image<T, TP> source, int width, int height, IImageSampler sampler)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
return Process(source, width, height, source.Bounds, default(Rectangle), sampler);
@ -129,7 +129,7 @@ namespace ImageProcessorCore
/// <param name="sampler">The processor to apply to the image.</param>
/// <returns>The <see cref="Image{T, TP}"/>.</returns>
public static Image<T, TP> Process<T, TP>(this Image<T, TP> source, int width, int height, Rectangle sourceRectangle, Rectangle targetRectangle, IImageSampler sampler)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
return PerformAction(source, false, (sourceImage, targetImage) => sampler.Apply(targetImage, sourceImage, width, height, targetRectangle, sourceRectangle));
@ -145,7 +145,7 @@ namespace ImageProcessorCore
/// <param name="action">The <see cref="Action"/> to perform against the image.</param>
/// <returns>The <see cref="Image{T, TP}"/>.</returns>
private static Image<T, TP> PerformAction<T, TP>(Image<T, TP> source, bool clone, Action<ImageBase<T, TP>, ImageBase<T, TP>> action)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
Image<T, TP> transformedImage = clone

2
src/ImageProcessorCore/Image/ImageFrame.cs

@ -11,7 +11,7 @@ namespace ImageProcessorCore
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
public class ImageFrame<T, TP> : ImageBase<T, TP>
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
/// <summary>

10
src/ImageProcessorCore/ImageProcessor.cs

@ -28,7 +28,7 @@ namespace ImageProcessorCore.Processors
/// <inheritdoc/>
public void Apply<T, TP>(ImageBase<T, TP> target, ImageBase<T, TP> source, Rectangle sourceRectangle)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
try
@ -51,7 +51,7 @@ namespace ImageProcessorCore.Processors
/// <inheritdoc/>
public void Apply<T, TP>(ImageBase<T, TP> target, ImageBase<T, TP> source, int width, int height, Rectangle targetRectangle = default(Rectangle), Rectangle sourceRectangle = default(Rectangle))
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
try
@ -100,7 +100,7 @@ namespace ImageProcessorCore.Processors
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw.
/// </param>
protected virtual void OnApply<T, TP>(ImageBase<T, TP> target, ImageBase<T, TP> source, Rectangle targetRectangle, Rectangle sourceRectangle)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
}
@ -127,7 +127,7 @@ namespace ImageProcessorCore.Processors
/// the result of image process as new image.
/// </remarks>
protected abstract void Apply<T, TP>(ImageBase<T, TP> target, ImageBase<T, TP> source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct;
/// <summary>
@ -145,7 +145,7 @@ namespace ImageProcessorCore.Processors
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw.
/// </param>
protected virtual void AfterApply<T, TP>(ImageBase<T, TP> target, ImageBase<T, TP> source, Rectangle targetRectangle, Rectangle sourceRectangle)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
}

2
src/ImageProcessorCore/PackedVector/Bgra32.cs

@ -13,7 +13,7 @@ namespace ImageProcessorCore
/// Packed vector type containing four 8-bit unsigned normalized values ranging from 0 to 255.
/// </summary>
[StructLayout(LayoutKind.Explicit)]
public struct Bgra32 : IPackedVector<Bgra32, uint>, IEquatable<Bgra32>
public struct Bgra32 : IPackedVector<uint>, IEquatable<Bgra32>
{
/// <summary>
/// Gets or sets the blue component.

3
src/ImageProcessorCore/PackedVector/IPackedVector.cs

@ -11,9 +11,8 @@ namespace ImageProcessorCore
/// An interface that converts packed vector types to and from <see cref="Vector4"/> values,
/// allowing multiple encodings to be manipulated in a generic way.
/// </summary>
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
public interface IPackedVector<T, TP> : IPackedVector
public interface IPackedVector<TP> : IPackedVector
where TP : struct
{
/// <summary>

9
src/ImageProcessorCore/PixelAccessor/IPixelAccessor.cs

@ -6,12 +6,14 @@
namespace ImageProcessorCore
{
using System;
/// <summary>
/// Encapsulates properties to provides per-pixel access to an images pixels.
/// </summary>
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
public interface IPixelAccessor<T, TP> : IPixelAccessor
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
/// <summary>
@ -33,6 +35,9 @@ namespace ImageProcessorCore
}
}
/// <summary>
/// Encapsulates properties to provides per-pixel access to an images pixels.
/// </summary>
public interface IPixelAccessor : IDisposable
{
/// <summary>

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

@ -24,7 +24,7 @@ namespace ImageProcessorCore
/// The <see cref="Rectangle"/>.
/// </returns>
public static Rectangle CalculateTargetLocationAndBounds<T, TP>(ImageBase<T, TP> source, ResizeOptions options)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
switch (options.Mode)
@ -56,7 +56,7 @@ namespace ImageProcessorCore
/// The <see cref="Rectangle"/>.
/// </returns>
private static Rectangle CalculateCropRectangle<T, TP>(ImageBase<T, TP> source, ResizeOptions options)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
int width = options.Size.Width;
@ -176,7 +176,7 @@ namespace ImageProcessorCore
/// The <see cref="Rectangle"/>.
/// </returns>
private static Rectangle CalculatePadRectangle<T, TP>(ImageBase<T, TP> source, ResizeOptions options)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
int width = options.Size.Width;
@ -258,7 +258,7 @@ namespace ImageProcessorCore
/// The <see cref="Rectangle"/>.
/// </returns>
private static Rectangle CalculateBoxPadRectangle<T, TP>(ImageBase<T, TP> source, ResizeOptions options)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
int width = options.Size.Width;
@ -346,7 +346,7 @@ namespace ImageProcessorCore
/// The <see cref="Rectangle"/>.
/// </returns>
private static Rectangle CalculateMaxRectangle<T, TP>(ImageBase<T, TP> source, ResizeOptions options)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
int width = options.Size.Width;
@ -388,7 +388,7 @@ namespace ImageProcessorCore
/// The <see cref="Rectangle"/>.
/// </returns>
private static Rectangle CalculateMinRectangle<T, TP>(ImageBase<T, TP> source, ResizeOptions options)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
int width = options.Size.Width;

10
src/ImageProcessorCore/Samplers/Resize.cs

@ -22,7 +22,7 @@ namespace ImageProcessorCore
/// <returns>The <see cref="Image{T}"/></returns>
/// <remarks>Passing zero for one of height or width within the resize options will automatically preserve the aspect ratio of the original image</remarks>
public static Image<T,TP> Resize<T,TP>(this Image<T,TP> source, ResizeOptions options, ProgressEventHandler progressHandler = null)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
// Ensure size is populated across both dimensions.
@ -52,7 +52,7 @@ namespace ImageProcessorCore
/// <returns>The <see cref="Image{T}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static Image<T,TP> Resize<T,TP>(this Image<T,TP> source, int width, int height, ProgressEventHandler progressHandler = null)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
return Resize(source, width, height, new BicubicResampler(), false, progressHandler);
@ -70,7 +70,7 @@ namespace ImageProcessorCore
/// <returns>The <see cref="Image{T}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static Image<T,TP> Resize<T,TP>(this Image<T,TP> source, int width, int height, bool compand, ProgressEventHandler progressHandler = null)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
return Resize(source, width, height, new BicubicResampler(), compand, progressHandler);
@ -89,7 +89,7 @@ namespace ImageProcessorCore
/// <returns>The <see cref="Image{T}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static Image<T,TP> Resize<T,TP>(this Image<T,TP> source, int width, int height, IResampler sampler, bool compand, ProgressEventHandler progressHandler = null)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
return Resize(source, width, height, sampler, source.Bounds, new Rectangle(0, 0, width, height), compand, progressHandler);
@ -115,7 +115,7 @@ namespace ImageProcessorCore
/// <returns>The <see cref="Image{T}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static Image<T,TP> Resize<T,TP>(this Image<T,TP> source, int width, int height, IResampler sampler, Rectangle sourceRectangle, Rectangle targetRectangle, bool compand = false, ProgressEventHandler progressHandler = null)
where T : IPackedVector<T, TP>, new()
where T : IPackedVector<TP>, new()
where TP : struct
{
if (width == 0 && height > 0)

Loading…
Cancel
Save