Browse Source

Remove new() type constraint

Former-commit-id: 60b0e004f0517fe6ffd7b0f2aef1d196ed3ef9fd
Former-commit-id: e42b121f44034c0d82ffdeac627cd0d214eb6780
Former-commit-id: 792ae7427d0028d2a012b100259e7ee72e1fc224
af/merge-core
James Jackson-South 10 years ago
parent
commit
2ab08b54a2
  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. 22
      src/ImageProcessorCore/Formats/IImageEncoder.cs
  8. 2
      src/ImageProcessorCore/Formats/Png/GrayscaleReader.cs
  9. 2
      src/ImageProcessorCore/Formats/Png/IColorReader.cs
  10. 2
      src/ImageProcessorCore/Formats/Png/PaletteIndexReader.cs
  11. 2
      src/ImageProcessorCore/Formats/Png/PngDecoder.cs
  12. 8
      src/ImageProcessorCore/Formats/Png/PngDecoderCore.cs
  13. 2
      src/ImageProcessorCore/Formats/Png/PngEncoder.cs
  14. 8
      src/ImageProcessorCore/Formats/Png/PngEncoderCore.cs
  15. 2
      src/ImageProcessorCore/Formats/Png/TrueColorReader.cs
  16. 2
      src/ImageProcessorCore/Image/IImageBase.cs
  17. 2
      src/ImageProcessorCore/Image/IImageFrame.cs
  18. 6
      src/ImageProcessorCore/Image/IImageProcessor.cs
  19. 2
      src/ImageProcessorCore/Image/Image.cs
  20. 2
      src/ImageProcessorCore/Image/ImageBase.cs
  21. 10
      src/ImageProcessorCore/Image/ImageExtensions.cs
  22. 2
      src/ImageProcessorCore/Image/ImageFrame.cs
  23. 10
      src/ImageProcessorCore/ImageProcessor.cs
  24. 2
      src/ImageProcessorCore/PixelAccessor/IPixelAccessor.cs
  25. 2
      src/ImageProcessorCore/Quantizers/IQuantizer.cs
  26. 2
      src/ImageProcessorCore/Quantizers/QuantizedImage.cs
  27. 6
      src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs
  28. 12
      src/ImageProcessorCore/Samplers/Options/ResizeHelper.cs
  29. 10
      src/ImageProcessorCore/Samplers/Resize.cs

2
src/ImageProcessorCore/Bootstrapper.cs

@ -80,7 +80,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<TP>, new()
where T : IPackedVector<TP>
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,TP}"/> 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<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
new BmpDecoderCore().Decode(image, stream);

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

@ -61,7 +61,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<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
this.currentStream = stream;
@ -197,7 +197,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<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
// Pixels per byte (bits per pixel)
@ -260,7 +260,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<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
// We divide here as we will store the colors in our floating point format.
@ -311,7 +311,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<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
int alignment;
@ -352,7 +352,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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
Guard.NotNull(image, nameof(image));
@ -129,7 +129,7 @@ namespace ImageProcessorCore.Formats
/// The <see cref="ImageBase{T,TP}"/> containing pixel data.
/// </param>
private void WriteImage<T, TP>(EndianBinaryWriter writer, ImageBase<T, TP> image)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
// TODO: Add more compression formats.
@ -163,7 +163,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<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
for (int y = pixels.Height - 1; y >= 0; y--)
@ -191,7 +191,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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
where TP : struct;
}
}

22
src/ImageProcessorCore/Formats/IImageEncoder.cs

@ -1,12 +1,7 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IImageEncoder.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// <copyright file="IImageEncoder.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Encapsulates properties and methods required for decoding an image to a stream.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessorCore.Formats
{
@ -43,13 +38,14 @@ namespace ImageProcessorCore.Formats
bool IsSupportedFileExtension(string extension);
/// <summary>
/// Encodes the image to the specified stream from the <see cref="ImageBase{T}"/>.
/// Encodes the image to the specified stream from the <see cref="ImageBase{T,P}"/>.
/// </summary>
/// <typeparam name="T">The type of pixels contained within the image.</typeparam>
/// <param name="image">The <see cref="ImageBase{T}"/> to encode from.</param>
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
/// <param name="image">The <see cref="ImageBase{T,P}"/> 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<TP>,
new() where TP : struct;
where T : IPackedVector<TP>
where TP : struct;
}
}

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

@ -34,7 +34,7 @@ namespace ImageProcessorCore.Formats
/// <inheritdoc/>
public void ReadScanline<T, TP>(byte[] scanline, T[] pixels, PngHeader header)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
int offset;

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

@ -23,7 +23,7 @@ namespace ImageProcessorCore.Formats
/// the width of the image and the height.
/// </param>
void ReadScanline<T, TP>(byte[] scanline, T[] pixels, PngHeader header)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct;
}
}

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

@ -40,7 +40,7 @@ namespace ImageProcessorCore.Formats
/// <inheritdoc/>
public void ReadScanline<T, TP>(byte[] scanline, T[] pixels, PngHeader header)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
byte[] newScanline = scanline.ToArrayByBitsLength(header.BitDepth);

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

@ -80,7 +80,7 @@ namespace ImageProcessorCore.Formats
/// <param name="image">The <see cref="ImageBase{T,TP}"/> 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<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
new PngDecoderCore().Decode(image, stream);

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

@ -76,7 +76,7 @@ namespace ImageProcessorCore.Formats
/// Thrown if the image is larger than the maximum allowable size.
/// </exception>
public void Decode<T, TP>(Image<T, TP> image, Stream stream)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
Image<T, TP> currentImage = image;
@ -194,7 +194,7 @@ namespace ImageProcessorCore.Formats
/// <param name="image">The image to read to.</param>
/// <param name="data">The data containing physical data.</param>
private void ReadPhysicalChunk<T, TP>(Image<T, TP> image, byte[] data)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
Array.Reverse(data, 0, 4);
@ -249,7 +249,7 @@ namespace ImageProcessorCore.Formats
/// <param name="colorReader">The color reader.</param>
/// <param name="colorTypeInformation">The color type information.</param>
private void ReadScanlines<T, TP>(MemoryStream dataStream, T[] pixels, IColorReader colorReader, PngColorTypeInformation colorTypeInformation)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
dataStream.Position = 0;
@ -332,7 +332,7 @@ namespace ImageProcessorCore.Formats
/// <param name="image">The image to decode to.</param>
/// <param name="data">The <see cref="T:byte[]"/> containing data.</param>
private void ReadTextChunk<T, TP>(Image<T, TP> image, byte[] data)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
int zeroIndex = 0;

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

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

8
src/ImageProcessorCore/Formats/Png/PngEncoderCore.cs

@ -70,7 +70,7 @@ namespace ImageProcessorCore.Formats
/// <param name="image">The <see cref="ImageBase{T,TP}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
public void Encode<T, TP>(ImageBase<T, TP> image, Stream stream)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
Guard.NotNull(image, nameof(image));
@ -208,7 +208,7 @@ namespace ImageProcessorCore.Formats
/// <param name="header">The <see cref="PngHeader"/>.</param>
/// <param name="image">The image to encode.</param>
private QuantizedImage<T, TP> WritePaletteChunk<T, TP>(Stream stream, PngHeader header, ImageBase<T, TP> image)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
if (this.Quality > 256)
@ -266,7 +266,7 @@ namespace ImageProcessorCore.Formats
/// <param name="stream">The <see cref="Stream"/> containing image data.</param>
/// <param name="imageBase">The image base.</param>
private void WritePhysicalChunk<T, TP>(Stream stream, ImageBase<T, TP> imageBase)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
Image<T, TP> image = imageBase as Image<T, TP>;
@ -319,7 +319,7 @@ namespace ImageProcessorCore.Formats
/// <param name="pixels">The image pixels.</param>
/// <param name="quantized">The quantized image.</param>
private void WriteDataChunks<T, TP>(Stream stream, IPixelAccessor<T, TP> pixels, QuantizedImage<T, TP> quantized)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
byte[] data;

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

@ -33,7 +33,7 @@ namespace ImageProcessorCore.Formats
/// <inheritdoc/>
public void ReadScanline<T, TP>(byte[] scanline, T[] pixels, PngHeader header)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
int offset;

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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
}

6
src/ImageProcessorCore/Image/IImageProcessor.cs

@ -54,8 +54,8 @@ 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<TP>,
new() where TP : struct;
where T : IPackedVector<TP>
where TP : struct;
/// <summary>
/// Applies the process to the specified portion of the specified <see cref="ImageBase{T, TP}"/> at the specified
@ -79,7 +79,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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
/// <summary>

10
src/ImageProcessorCore/ImageProcessor.cs

@ -32,7 +32,7 @@ namespace ImageProcessorCore.Processors
/// <inheritdoc/>
public void Apply<T, TP>(ImageBase<T, TP> target, ImageBase<T, TP> source, Rectangle sourceRectangle)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
try
@ -55,7 +55,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<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
try
@ -104,7 +104,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<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
}
@ -131,7 +131,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<TP>, new()
where T : IPackedVector<TP>
where TP : struct;
/// <summary>
@ -149,7 +149,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<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
}

2
src/ImageProcessorCore/PixelAccessor/IPixelAccessor.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 IPixelAccessor<T, TP> : IPixelAccessor
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
/// <summary>

2
src/ImageProcessorCore/Quantizers/IQuantizer.cs

@ -26,7 +26,7 @@ namespace ImageProcessorCore.Quantizers
/// A <see cref="T:QuantizedImage"/> representing a quantized version of the image pixels.
/// </returns>
QuantizedImage<T, TP> Quantize<T, TP>(ImageBase<T, TP> image, int maxColors)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct;
}
}

2
src/ImageProcessorCore/Quantizers/QuantizedImage.cs

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

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

@ -116,7 +116,7 @@ namespace ImageProcessorCore.Quantizers
/// <inheritdoc/>
public QuantizedImage<T, TP> Quantize<T, TP>(ImageBase<T, TP> image, int maxColors)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
Guard.NotNull(image, nameof(image));
@ -326,7 +326,7 @@ namespace ImageProcessorCore.Quantizers
/// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
/// <param name="pixels">The pixel accessor.</param>
private void Build3DHistogram<T, TP>(IPixelAccessor<T, TP> pixels)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
for (int y = 0; y < pixels.Height; y++)
@ -728,7 +728,7 @@ namespace ImageProcessorCore.Quantizers
/// <param name="cube">The cube.</param>
/// <returns>The result.</returns>
private QuantizedImage<T, TP> GenerateResult<T, TP>(IPixelAccessor<T, TP> imagePixels, int colorCount, Box[] cube)
where T : IPackedVector<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
List<T> pallette = new List<T>();

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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
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<TP>, new()
where T : IPackedVector<TP>
where TP : struct
{
if (width == 0 && height > 0)

Loading…
Cancel
Save