Browse Source

Add setter to IPackedVector<TP>

Former-commit-id: 8f90f6fd99515e8cbf50184baeaefd93466bb39c
Former-commit-id: f1e9aa552dc446eedb450aa7ed1a9f6ef87a5001
Former-commit-id: 15c3d89bf472544d8c89dd7da2f45dfffbb441e6
pull/1/head
James Jackson-South 10 years ago
parent
commit
e70f07426e
  1. 14
      src/ImageProcessorCore/Colors/Color.cs
  2. 29
      src/ImageProcessorCore/Colors/PackedVector/IPackedVector.cs
  3. 2
      src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs
  4. 2
      src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs
  5. 4
      src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs
  6. 2
      src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs
  7. 2
      src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs
  8. 2
      src/ImageProcessorCore/Filters/Processors/ColorMatrix/ColorMatrixFilter.cs
  9. 2
      src/ImageProcessorCore/Filters/Processors/ColorMatrix/LomographProcessor.cs
  10. 4
      src/ImageProcessorCore/Filters/Processors/ColorMatrix/PolaroidProcessor.cs
  11. 2
      src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs
  12. 2
      src/ImageProcessorCore/Filters/Processors/Convolution/Convolution2DFilter.cs
  13. 2
      src/ImageProcessorCore/Filters/Processors/Convolution/Convolution2PassFilter.cs
  14. 2
      src/ImageProcessorCore/Filters/Processors/Convolution/ConvolutionFilter.cs
  15. 4
      src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs
  16. 2
      src/ImageProcessorCore/Filters/Processors/InvertProcessor.cs
  17. 4
      src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs
  18. 8
      src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs
  19. 2
      src/ImageProcessorCore/Formats/Gif/GifDecoderCore.cs
  20. 2
      src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id
  21. 4
      src/ImageProcessorCore/Formats/Png/GrayscaleReader.cs
  22. 4
      src/ImageProcessorCore/Formats/Png/PaletteIndexReader.cs
  23. 4
      src/ImageProcessorCore/Formats/Png/TrueColorReader.cs
  24. 4
      src/ImageProcessorCore/Quantizers/Octree/OctreeQuantizer.cs
  25. 2
      src/ImageProcessorCore/Quantizers/Palette/PaletteQuantizer.cs
  26. 2
      src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs
  27. 4
      src/ImageProcessorCore/Samplers/Processors/CompandingResizeProcessor.cs
  28. 4
      src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs
  29. 28
      tests/ImageProcessorCore.Tests/Colors/ColorTests.cs

14
src/ImageProcessorCore/Colors/Color.cs

@ -49,7 +49,7 @@ namespace ImageProcessorCore
/// The packed value. /// The packed value.
/// </summary> /// </summary>
[FieldOffset(0)] [FieldOffset(0)]
private readonly uint packedValue; private uint packedValue;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Color"/> struct. /// Initializes a new instance of the <see cref="Color"/> struct.
@ -192,13 +192,19 @@ namespace ImageProcessorCore
} }
/// <inheritdoc/> /// <inheritdoc/>
public uint PackedValue() public uint GetPackedValue()
{ {
return this.packedValue; return this.packedValue;
} }
/// <inheritdoc/> /// <inheritdoc/>
public void PackVector(Vector4 vector) public void SetPackedValue(uint value)
{
this.packedValue = value;
}
/// <inheritdoc/>
public void PackFromVector4(Vector4 vector)
{ {
Vector4 clamped = Vector4.Clamp(vector, Vector4.Zero, Vector4.One) * 255F; Vector4 clamped = Vector4.Clamp(vector, Vector4.Zero, Vector4.One) * 255F;
this.R = (byte)Math.Round(clamped.X); this.R = (byte)Math.Round(clamped.X);
@ -208,7 +214,7 @@ namespace ImageProcessorCore
} }
/// <inheritdoc/> /// <inheritdoc/>
public void PackBytes(byte x, byte y, byte z, byte w) public void PackFromBytes(byte x, byte y, byte z, byte w)
{ {
this.R = x; this.R = x;
this.G = y; this.G = y;

29
src/ImageProcessorCore/Colors/PackedVector/IPackedVector.cs

@ -9,20 +9,27 @@ namespace ImageProcessorCore
/// <summary> /// <summary>
/// An interface that converts packed vector types to and from <see cref="Vector4"/> values, /// An interface that converts packed vector types to and from <see cref="Vector4"/> values,
/// allowing multiple encodings to be manipulated in a generic way. /// allowing multiple encodings to be manipulated in a generic manner.
/// </summary> /// </summary>
/// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam> /// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
public interface IPackedVector<TP> : IPackedVector public interface IPackedVector<TP> : IPackedVector
where TP : struct where TP : struct
{ {
/// <summary> /// <summary>
/// Gets the packed representation of the value. /// Directly gets the packed representation of the packed vector.
/// Typically packed in least to greatest significance order. /// Typically packed in least to greatest significance order.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// The <see cref="TP"/>. /// The <see cref="TP"/>.
/// </returns> /// </returns>
TP PackedValue(); TP GetPackedValue();
/// <summary>
/// Directly sets the packed representation of the packed vector.
/// Typically packed in least to greatest significance order.
/// </summary>
/// <param name="value">The packed value.</param>
void SetPackedValue(TP value);
} }
/// <summary> /// <summary>
@ -33,17 +40,17 @@ namespace ImageProcessorCore
/// <summary> /// <summary>
/// Sets the packed representation from a <see cref="Vector4"/>. /// Sets the packed representation from a <see cref="Vector4"/>.
/// </summary> /// </summary>
/// <param name="vector">The vector to pack.</param> /// <param name="vector">The vector to create the packed representation from.</param>
void PackVector(Vector4 vector); void PackFromVector4(Vector4 vector);
/// <summary> /// <summary>
/// Sets the packed representation from a <see cref="Vector4"/>. /// Sets the packed representation from a <see cref="T:byte[]"/>.
/// </summary> /// </summary>
/// <param name="x">The x-component.</param> /// <param name="x">The x-component to create the packed representation from.</param>
/// <param name="y">The y-component.</param> /// <param name="y">The y-component to create the packed representation from.</param>
/// <param name="z">The z-component.</param> /// <param name="z">The z-component to create the packed representation from.</param>
/// <param name="w">The w-component.</param> /// <param name="w">The w-component to create the packed representation from.</param>
void PackBytes(byte x, byte y, byte z, byte w); void PackFromBytes(byte x, byte y, byte z, byte w);
/// <summary> /// <summary>
/// Expands the packed representation into a <see cref="Vector4"/>. /// Expands the packed representation into a <see cref="Vector4"/>.

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

@ -62,7 +62,7 @@ namespace ImageProcessorCore.Processors
color *= alphaVector; color *= alphaVector;
T packed = default(T); T packed = default(T);
packed.PackVector(color); packed.PackFromVector4(color);
targetPixels[x, y] = packed; targetPixels[x, y] = packed;
} }

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

@ -71,7 +71,7 @@ namespace ImageProcessorCore.Processors
} }
T packed = default(T); T packed = default(T);
packed.PackVector(color); packed.PackFromVector4(color);
targetPixels[x, y] = packed; targetPixels[x, y] = packed;
} }

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

@ -32,11 +32,11 @@ namespace ImageProcessorCore.Processors
this.Value = threshold; this.Value = threshold;
T upper = default(T); T upper = default(T);
upper.PackVector(Color.White.ToVector4()); upper.PackFromVector4(Color.White.ToVector4());
this.UpperColor = upper; this.UpperColor = upper;
T lower = default(T); T lower = default(T);
lower.PackVector(Color.Black.ToVector4()); lower.PackFromVector4(Color.Black.ToVector4());
this.LowerColor = lower; this.LowerColor = lower;
} }

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

@ -81,7 +81,7 @@ namespace ImageProcessorCore.Processors
} }
T packed = default(T); T packed = default(T);
packed.PackVector(color); packed.PackFromVector4(color);
targetPixels[x, y] = packed; targetPixels[x, y] = packed;
} }

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

@ -64,7 +64,7 @@ namespace ImageProcessorCore.Processors
vector = new Vector4(transformed, vector.W); vector = new Vector4(transformed, vector.W);
T packed = default(T); T packed = default(T);
packed.PackVector(vector.Compress()); packed.PackFromVector4(vector.Compress());
targetPixels[x, y] = packed; targetPixels[x, y] = packed;
} }

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

@ -71,7 +71,7 @@ namespace ImageProcessorCore.Processors
Vector3 transformed = Vector3.Transform(new Vector3(vector.X, vector.Y, vector.Z), matrix); Vector3 transformed = Vector3.Transform(new Vector3(vector.X, vector.Y, vector.Z), matrix);
vector = new Vector4(transformed, vector.W); vector = new Vector4(transformed, vector.W);
T packed = default(T); T packed = default(T);
packed.PackVector(compand ? vector.Compress() : vector); packed.PackFromVector4(compand ? vector.Compress() : vector);
return packed; return packed;
} }
} }

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

@ -31,7 +31,7 @@ namespace ImageProcessorCore.Processors
protected override void AfterApply(ImageBase<T, TP> target, ImageBase<T, TP> source, Rectangle targetRectangle, Rectangle sourceRectangle) protected override void AfterApply(ImageBase<T, TP> target, ImageBase<T, TP> source, Rectangle targetRectangle, Rectangle sourceRectangle)
{ {
T packed = default(T); T packed = default(T);
packed.PackBytes(0, 10, 0, 255); packed.PackFromBytes(0, 10, 0, 255);
new VignetteProcessor<T, TP> { VignetteColor = packed }.Apply(target, target, targetRectangle); new VignetteProcessor<T, TP> { VignetteColor = packed }.Apply(target, target, targetRectangle);
} }
} }

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

@ -37,11 +37,11 @@ namespace ImageProcessorCore.Processors
protected override void AfterApply(ImageBase<T, TP> target, ImageBase<T, TP> source, Rectangle targetRectangle, Rectangle sourceRectangle) protected override void AfterApply(ImageBase<T, TP> target, ImageBase<T, TP> source, Rectangle targetRectangle, Rectangle sourceRectangle)
{ {
T packedV = default(T); T packedV = default(T);
packedV.PackBytes(102, 34, 0, 255); packedV.PackFromBytes(102, 34, 0, 255);
new VignetteProcessor<T, TP> { VignetteColor = packedV }.Apply(target, target, targetRectangle); new VignetteProcessor<T, TP> { VignetteColor = packedV }.Apply(target, target, targetRectangle);
T packedG = default(T); T packedG = default(T);
packedG.PackBytes(255, 153, 102, 178); packedG.PackFromBytes(255, 153, 102, 178);
new GlowProcessor<T, TP> new GlowProcessor<T, TP>
{ {
GlowColor = packedG, GlowColor = packedG,

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

@ -64,7 +64,7 @@ namespace ImageProcessorCore.Processors
vector *= contrastVector; vector *= contrastVector;
vector += shiftVector; vector += shiftVector;
T packed = default(T); T packed = default(T);
packed.PackVector(vector.Compress()); packed.PackFromVector4(vector.Compress());
targetPixels[x, y] = packed; targetPixels[x, y] = packed;
} }
this.OnRowProcessed(); this.OnRowProcessed();

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

@ -109,7 +109,7 @@ namespace ImageProcessorCore.Processors
Vector4 targetColor = targetPixels[x, y].ToVector4(); Vector4 targetColor = targetPixels[x, y].ToVector4();
T packed = default(T); T packed = default(T);
packed.PackVector(new Vector4(red, green, blue, targetColor.Z)); packed.PackFromVector4(new Vector4(red, green, blue, targetColor.Z));
targetPixels[x, y] = packed; targetPixels[x, y] = packed;
} }
this.OnRowProcessed(); this.OnRowProcessed();

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

@ -97,7 +97,7 @@ namespace ImageProcessorCore.Processors
} }
T packed = default(T); T packed = default(T);
packed.PackVector(destination); packed.PackFromVector4(destination);
targetPixels[x, y] = packed; targetPixels[x, y] = packed;
} }

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

@ -83,7 +83,7 @@ namespace ImageProcessorCore.Processors
Vector4 targetColor = targetPixels[x, y].ToVector4(); Vector4 targetColor = targetPixels[x, y].ToVector4();
T packed = default(T); T packed = default(T);
packed.PackVector(new Vector4(red, green, blue, targetColor.Z)); packed.PackFromVector4(new Vector4(red, green, blue, targetColor.Z));
targetPixels[x, y] = packed; targetPixels[x, y] = packed;
} }

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

@ -23,7 +23,7 @@ namespace ImageProcessorCore.Processors
/// </summary> /// </summary>
public GlowProcessor() public GlowProcessor()
{ {
this.GlowColor.PackVector(Color.White.ToVector4()); this.GlowColor.PackFromVector4(Color.White.ToVector4());
} }
/// <summary> /// <summary>
@ -68,7 +68,7 @@ namespace ImageProcessorCore.Processors
Vector4 sourceColor = sourcePixels[x, y].ToVector4(); Vector4 sourceColor = sourcePixels[x, y].ToVector4();
Vector4 result = Vector4.Lerp(glowColor.ToVector4(), sourceColor, .5f * (distance / maxDistance)); Vector4 result = Vector4.Lerp(glowColor.ToVector4(), sourceColor, .5f * (distance / maxDistance));
T packed = default(T); T packed = default(T);
packed.PackVector(result); packed.PackFromVector4(result);
targetPixels[x, y] = packed; targetPixels[x, y] = packed;
} }

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

@ -41,7 +41,7 @@ namespace ImageProcessorCore.Processors
Vector3 vector = inverseVector - new Vector3(color.X, color.Y, color.Z); Vector3 vector = inverseVector - new Vector3(color.X, color.Y, color.Z);
T packed = default(T); T packed = default(T);
packed.PackVector(new Vector4(vector, color.W)); packed.PackFromVector4(new Vector4(vector, color.W));
targetPixels[x, y] = packed; targetPixels[x, y] = packed;
} }

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

@ -23,7 +23,7 @@ namespace ImageProcessorCore.Processors
/// </summary> /// </summary>
public VignetteProcessor() public VignetteProcessor()
{ {
this.VignetteColor.PackVector(Color.Black.ToVector4()); this.VignetteColor.PackFromVector4(Color.Black.ToVector4());
} }
/// <summary> /// <summary>
@ -67,7 +67,7 @@ namespace ImageProcessorCore.Processors
Vector4 sourceColor = sourcePixels[x, y].ToVector4(); Vector4 sourceColor = sourcePixels[x, y].ToVector4();
Vector4 result = Vector4.Lerp(vignetteColor.ToVector4(), sourceColor, 1 - .9f * (distance / maxDistance)); Vector4 result = Vector4.Lerp(vignetteColor.ToVector4(), sourceColor, 1 - .9f * (distance / maxDistance));
T packed = default(T); T packed = default(T);
packed.PackVector(result); packed.PackFromVector4(result);
targetPixels[x, y] = packed; targetPixels[x, y] = packed;
} }

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

@ -243,7 +243,7 @@ namespace ImageProcessorCore.Formats
// Stored in b-> g-> r order. // Stored in b-> g-> r order.
T packed = default(T); T packed = default(T);
packed.PackBytes(colors[colorIndex + 2], colors[colorIndex + 1], colors[colorIndex], 255); packed.PackFromBytes(colors[colorIndex + 2], colors[colorIndex + 1], colors[colorIndex], 255);
imageData[arrayOffset] = packed; imageData[arrayOffset] = packed;
} }
} }
@ -295,7 +295,7 @@ namespace ImageProcessorCore.Formats
// Stored in b-> g-> r order. // Stored in b-> g-> r order.
T packed = default(T); T packed = default(T);
packed.PackBytes(r, g, b, 255); packed.PackFromBytes(r, g, b, 255);
imageData[arrayOffset] = packed; imageData[arrayOffset] = packed;
} }
}); });
@ -336,7 +336,7 @@ namespace ImageProcessorCore.Formats
// We divide by 255 as we will store the colors in our floating point format. // We divide by 255 as we will store the colors in our floating point format.
// Stored in b-> g-> r-> a order. // Stored in b-> g-> r-> a order.
T packed = default(T); T packed = default(T);
packed.PackBytes(data[offset + 2], data[offset + 1], data[offset], 255); packed.PackFromBytes(data[offset + 2], data[offset + 1], data[offset], 255);
imageData[arrayOffset] = packed; imageData[arrayOffset] = packed;
} }
}); });
@ -376,7 +376,7 @@ namespace ImageProcessorCore.Formats
// Stored in b-> g-> r-> a order. // Stored in b-> g-> r-> a order.
T packed = default(T); T packed = default(T);
packed.PackBytes(data[offset + 2], data[offset + 1], data[offset], data[offset + 3]); packed.PackFromBytes(data[offset + 2], data[offset + 1], data[offset], data[offset + 3]);
imageData[arrayOffset] = packed; imageData[arrayOffset] = packed;
} }
}); });

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

@ -360,7 +360,7 @@ namespace ImageProcessorCore.Formats
int indexOffset = index * 3; int indexOffset = index * 3;
T pixel = default(T); T pixel = default(T);
pixel.PackBytes(colorTable[indexOffset], colorTable[indexOffset + 1], colorTable[indexOffset + 2], 255); pixel.PackFromBytes(colorTable[indexOffset], colorTable[indexOffset + 1], colorTable[indexOffset + 2], 255);
this.currentFrame[offset] = pixel; this.currentFrame[offset] = pixel;
} }

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

@ -1 +1 @@
09cbf92c0d7d3e4659626b60663612836e1e90e7 adc0f0265d9f43bfcc4b6e12b48eda9c8f48b81a

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

@ -52,7 +52,7 @@ namespace ImageProcessorCore.Formats
byte a = newScanline[(x * 2) + 1]; byte a = newScanline[(x * 2) + 1];
T color = default(T); T color = default(T);
color.PackBytes(rgb, rgb, rgb, a); color.PackFromBytes(rgb, rgb, rgb, a);
pixels[offset] = color; pixels[offset] = color;
} }
} }
@ -64,7 +64,7 @@ namespace ImageProcessorCore.Formats
byte rgb = newScanline[x]; byte rgb = newScanline[x];
T color = default(T); T color = default(T);
color.PackBytes(rgb, rgb, rgb, 255); color.PackFromBytes(rgb, rgb, rgb, 255);
pixels[offset] = color; pixels[offset] = color;
} }

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

@ -66,7 +66,7 @@ namespace ImageProcessorCore.Formats
: (byte)255; : (byte)255;
T color = default(T); T color = default(T);
color.PackBytes(r, g, b, a); color.PackFromBytes(r, g, b, a);
pixels[offset] = color; pixels[offset] = color;
} }
} }
@ -84,7 +84,7 @@ namespace ImageProcessorCore.Formats
byte b = this.palette[pixelOffset + 2]; byte b = this.palette[pixelOffset + 2];
T color = default(T); T color = default(T);
color.PackBytes(r, g, b, 255); color.PackFromBytes(r, g, b, 255);
pixels[offset] = color; pixels[offset] = color;
} }
} }

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

@ -53,7 +53,7 @@ namespace ImageProcessorCore.Formats
byte a = newScanline[x + 3]; byte a = newScanline[x + 3];
T color = default(T); T color = default(T);
color.PackBytes(r, g, b, a); color.PackFromBytes(r, g, b, a);
pixels[offset] = color; pixels[offset] = color;
} }
@ -70,7 +70,7 @@ namespace ImageProcessorCore.Formats
byte b = newScanline[pixelOffset + 2]; byte b = newScanline[pixelOffset + 2];
T color = default(T); T color = default(T);
color.PackBytes(r, g, b, 255); color.PackFromBytes(r, g, b, 255);
pixels[offset] = color; pixels[offset] = color;
} }
} }

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

@ -197,7 +197,7 @@ namespace ImageProcessorCore.Quantizers
/// </param> /// </param>
public void AddColor(T pixel) public void AddColor(T pixel)
{ {
TP packed = pixel.PackedValue(); TP packed = pixel.GetPackedValue();
// Check if this request is for the same color as the last // Check if this request is for the same color as the last
if (this.previousColor.Equals(packed)) if (this.previousColor.Equals(packed))
{ {
@ -468,7 +468,7 @@ namespace ImageProcessorCore.Quantizers
// And set the color of the palette entry // And set the color of the palette entry
T pixel = default(T); T pixel = default(T);
pixel.PackBytes(r, g, b, 255); pixel.PackFromBytes(r, g, b, 255);
palette.Add(pixel); palette.Add(pixel);
} }
else else

2
src/ImageProcessorCore/Quantizers/Palette/PaletteQuantizer.cs

@ -47,7 +47,7 @@ namespace ImageProcessorCore.Quantizers
foreach (Color c in constants) foreach (Color c in constants)
{ {
T packed = default(T); T packed = default(T);
packed.PackVector(c.ToVector4()); packed.PackFromVector4(c.ToVector4());
safe.Add(packed); safe.Add(packed);
} }

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

@ -745,7 +745,7 @@ namespace ImageProcessorCore.Quantizers
byte a = (byte)(Volume(cube[k], this.vma) / weight); byte a = (byte)(Volume(cube[k], this.vma) / weight);
T color = default(T); T color = default(T);
color.PackBytes(r, g, b, a); color.PackFromBytes(r, g, b, a);
if (color.Equals(default(T))) if (color.Equals(default(T)))
{ {

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

@ -124,7 +124,7 @@ namespace ImageProcessorCore.Processors
} }
T d = default(T); T d = default(T);
d.PackVector(destination.Compress()); d.PackFromVector4(destination.Compress());
firstPassPixels[x, y] = d; firstPassPixels[x, y] = d;
} }
}); });
@ -151,7 +151,7 @@ namespace ImageProcessorCore.Processors
} }
T d = default(T); T d = default(T);
d.PackVector(destination.Compress()); d.PackFromVector4(destination.Compress());
targetPixels[x, y] = d; targetPixels[x, y] = d;
} }

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

@ -123,7 +123,7 @@ namespace ImageProcessorCore.Processors
} }
T d = default(T); T d = default(T);
d.PackVector(destination); d.PackFromVector4(destination);
firstPassPixels[x, y] = d; firstPassPixels[x, y] = d;
} }
}); });
@ -150,7 +150,7 @@ namespace ImageProcessorCore.Processors
} }
T d = default(T); T d = default(T);
d.PackVector(destination); d.PackFromVector4(destination);
targetPixels[x, y] = d; targetPixels[x, y] = d;
} }

28
tests/ImageProcessorCore.Tests/Colors/Class.cs → tests/ImageProcessorCore.Tests/Colors/ColorTests.cs

@ -75,23 +75,17 @@ namespace ImageProcessorCore.Tests
Assert.Equal(0, color3.B); Assert.Equal(0, color3.B);
Assert.Equal(255, color3.A); Assert.Equal(255, color3.A);
//Color color4 = new Color(new Vector3(1, .1f, .133f)); Color color4 = new Color(new Vector3(1, .1f, .133f));
//Assert.Equal(1, color4.R, 1); Assert.Equal(255, color4.R);
//Assert.Equal(.1f, color4.G, 1); Assert.Equal(Math.Round(.1f * 255), color4.G);
//Assert.Equal(.133f, color4.B, 3); Assert.Equal(Math.Round(.133f * 255), color4.B);
//Assert.Equal(1, color4.A, 1); Assert.Equal(255, color4.A);
//Color color5 = new Color(new Vector3(1, .1f, .133f), .5f); Color color5 = new Color(new Vector4(1, .1f, .133f, .5f));
//Assert.Equal(1, color5.R, 1); Assert.Equal(255, color5.R);
//Assert.Equal(.1f, color5.G, 1); Assert.Equal(Math.Round(.1f * 255), color5.G);
//Assert.Equal(.133f, color5.B, 3); Assert.Equal(Math.Round(.133f * 255), color5.B);
//Assert.Equal(.5f, color5.A, 1); Assert.Equal(Math.Round(.5f * 255), color5.A);
Color color6 = new Color(new Vector4(1, .1f, .133f, .5f));
Assert.Equal(255, color6.R);
Assert.Equal(Math.Round(.1f * 255), color6.G);
Assert.Equal(Math.Round(.133f * 255), color6.B);
Assert.Equal(Math.Round(.5f * 255), color6.A);
} }
/// <summary> /// <summary>
@ -102,7 +96,7 @@ namespace ImageProcessorCore.Tests
{ {
const string First = "FF000000"; const string First = "FF000000";
Color color = Color.Black; Color color = Color.Black;
string second = color.PackedValue().ToString("X"); string second = color.GetPackedValue().ToString("X");
Assert.Equal(First, second); Assert.Equal(First, second);
} }
} }
Loading…
Cancel
Save