diff --git a/src/ImageProcessorCore/Colors/Color.cs b/src/ImageProcessorCore/Colors/Color.cs index 69bce48536..d5570d6470 100644 --- a/src/ImageProcessorCore/Colors/Color.cs +++ b/src/ImageProcessorCore/Colors/Color.cs @@ -49,7 +49,7 @@ namespace ImageProcessorCore /// The packed value. /// [FieldOffset(0)] - private readonly uint packedValue; + private uint packedValue; /// /// Initializes a new instance of the struct. @@ -192,13 +192,19 @@ namespace ImageProcessorCore } /// - public uint PackedValue() + public uint GetPackedValue() { return this.packedValue; } /// - public void PackVector(Vector4 vector) + public void SetPackedValue(uint value) + { + this.packedValue = value; + } + + /// + public void PackFromVector4(Vector4 vector) { Vector4 clamped = Vector4.Clamp(vector, Vector4.Zero, Vector4.One) * 255F; this.R = (byte)Math.Round(clamped.X); @@ -208,7 +214,7 @@ namespace ImageProcessorCore } /// - 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.G = y; diff --git a/src/ImageProcessorCore/Colors/PackedVector/IPackedVector.cs b/src/ImageProcessorCore/Colors/PackedVector/IPackedVector.cs index 99cd70d748..05b593e67e 100644 --- a/src/ImageProcessorCore/Colors/PackedVector/IPackedVector.cs +++ b/src/ImageProcessorCore/Colors/PackedVector/IPackedVector.cs @@ -9,20 +9,27 @@ namespace ImageProcessorCore /// /// An interface that converts packed vector types to and from values, - /// allowing multiple encodings to be manipulated in a generic way. + /// allowing multiple encodings to be manipulated in a generic manner. /// /// The packed format. long, float. public interface IPackedVector : IPackedVector where TP : struct { /// - /// Gets the packed representation of the value. + /// Directly gets the packed representation of the packed vector. /// Typically packed in least to greatest significance order. /// /// /// The . /// - TP PackedValue(); + TP GetPackedValue(); + + /// + /// Directly sets the packed representation of the packed vector. + /// Typically packed in least to greatest significance order. + /// + /// The packed value. + void SetPackedValue(TP value); } /// @@ -33,17 +40,17 @@ namespace ImageProcessorCore /// /// Sets the packed representation from a . /// - /// The vector to pack. - void PackVector(Vector4 vector); + /// The vector to create the packed representation from. + void PackFromVector4(Vector4 vector); /// - /// Sets the packed representation from a . + /// Sets the packed representation from a . /// - /// The x-component. - /// The y-component. - /// The z-component. - /// The w-component. - void PackBytes(byte x, byte y, byte z, byte w); + /// The x-component to create the packed representation from. + /// The y-component to create the packed representation from. + /// The z-component to create the packed representation from. + /// The w-component to create the packed representation from. + void PackFromBytes(byte x, byte y, byte z, byte w); /// /// Expands the packed representation into a . diff --git a/src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs b/src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs index bf5da0551d..fa090fc741 100644 --- a/src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs @@ -62,7 +62,7 @@ namespace ImageProcessorCore.Processors color *= alphaVector; T packed = default(T); - packed.PackVector(color); + packed.PackFromVector4(color); targetPixels[x, y] = packed; } diff --git a/src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs b/src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs index 03ff6b40b6..7e275a1f58 100644 --- a/src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs @@ -71,7 +71,7 @@ namespace ImageProcessorCore.Processors } T packed = default(T); - packed.PackVector(color); + packed.PackFromVector4(color); targetPixels[x, y] = packed; } diff --git a/src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs b/src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs index 28d7ffd2c5..9d42fce493 100644 --- a/src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs @@ -32,11 +32,11 @@ namespace ImageProcessorCore.Processors this.Value = threshold; T upper = default(T); - upper.PackVector(Color.White.ToVector4()); + upper.PackFromVector4(Color.White.ToVector4()); this.UpperColor = upper; T lower = default(T); - lower.PackVector(Color.Black.ToVector4()); + lower.PackFromVector4(Color.Black.ToVector4()); this.LowerColor = lower; } diff --git a/src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs b/src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs index 724d7c7485..3d74010eea 100644 --- a/src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs @@ -81,7 +81,7 @@ namespace ImageProcessorCore.Processors } T packed = default(T); - packed.PackVector(color); + packed.PackFromVector4(color); targetPixels[x, y] = packed; } diff --git a/src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs b/src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs index 4d0bd1b56c..b8c7bc441e 100644 --- a/src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs @@ -64,7 +64,7 @@ namespace ImageProcessorCore.Processors vector = new Vector4(transformed, vector.W); T packed = default(T); - packed.PackVector(vector.Compress()); + packed.PackFromVector4(vector.Compress()); targetPixels[x, y] = packed; } diff --git a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/ColorMatrixFilter.cs b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/ColorMatrixFilter.cs index f77cf654ab..67571471c8 100644 --- a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/ColorMatrixFilter.cs +++ b/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); vector = new Vector4(transformed, vector.W); T packed = default(T); - packed.PackVector(compand ? vector.Compress() : vector); + packed.PackFromVector4(compand ? vector.Compress() : vector); return packed; } } diff --git a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/LomographProcessor.cs b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/LomographProcessor.cs index cfdc628935..f701d4d55a 100644 --- a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/LomographProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/LomographProcessor.cs @@ -31,7 +31,7 @@ namespace ImageProcessorCore.Processors protected override void AfterApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle) { T packed = default(T); - packed.PackBytes(0, 10, 0, 255); + packed.PackFromBytes(0, 10, 0, 255); new VignetteProcessor { VignetteColor = packed }.Apply(target, target, targetRectangle); } } diff --git a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/PolaroidProcessor.cs b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/PolaroidProcessor.cs index 7a0263bd05..de56a9e00c 100644 --- a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/PolaroidProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/PolaroidProcessor.cs @@ -37,11 +37,11 @@ namespace ImageProcessorCore.Processors protected override void AfterApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle) { T packedV = default(T); - packedV.PackBytes(102, 34, 0, 255); + packedV.PackFromBytes(102, 34, 0, 255); new VignetteProcessor { VignetteColor = packedV }.Apply(target, target, targetRectangle); T packedG = default(T); - packedG.PackBytes(255, 153, 102, 178); + packedG.PackFromBytes(255, 153, 102, 178); new GlowProcessor { GlowColor = packedG, diff --git a/src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs b/src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs index 25e446d145..4f791caad0 100644 --- a/src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs @@ -64,7 +64,7 @@ namespace ImageProcessorCore.Processors vector *= contrastVector; vector += shiftVector; T packed = default(T); - packed.PackVector(vector.Compress()); + packed.PackFromVector4(vector.Compress()); targetPixels[x, y] = packed; } this.OnRowProcessed(); diff --git a/src/ImageProcessorCore/Filters/Processors/Convolution/Convolution2DFilter.cs b/src/ImageProcessorCore/Filters/Processors/Convolution/Convolution2DFilter.cs index ef024bcfb7..3b6edcf573 100644 --- a/src/ImageProcessorCore/Filters/Processors/Convolution/Convolution2DFilter.cs +++ b/src/ImageProcessorCore/Filters/Processors/Convolution/Convolution2DFilter.cs @@ -109,7 +109,7 @@ namespace ImageProcessorCore.Processors Vector4 targetColor = targetPixels[x, y].ToVector4(); 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; } this.OnRowProcessed(); diff --git a/src/ImageProcessorCore/Filters/Processors/Convolution/Convolution2PassFilter.cs b/src/ImageProcessorCore/Filters/Processors/Convolution/Convolution2PassFilter.cs index 09a591ec11..b21e005152 100644 --- a/src/ImageProcessorCore/Filters/Processors/Convolution/Convolution2PassFilter.cs +++ b/src/ImageProcessorCore/Filters/Processors/Convolution/Convolution2PassFilter.cs @@ -97,7 +97,7 @@ namespace ImageProcessorCore.Processors } T packed = default(T); - packed.PackVector(destination); + packed.PackFromVector4(destination); targetPixels[x, y] = packed; } diff --git a/src/ImageProcessorCore/Filters/Processors/Convolution/ConvolutionFilter.cs b/src/ImageProcessorCore/Filters/Processors/Convolution/ConvolutionFilter.cs index 45279550db..9fd1e19ee8 100644 --- a/src/ImageProcessorCore/Filters/Processors/Convolution/ConvolutionFilter.cs +++ b/src/ImageProcessorCore/Filters/Processors/Convolution/ConvolutionFilter.cs @@ -83,7 +83,7 @@ namespace ImageProcessorCore.Processors Vector4 targetColor = targetPixels[x, y].ToVector4(); 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; } diff --git a/src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs b/src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs index afe8b1b290..18eab81f5a 100644 --- a/src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs @@ -23,7 +23,7 @@ namespace ImageProcessorCore.Processors /// public GlowProcessor() { - this.GlowColor.PackVector(Color.White.ToVector4()); + this.GlowColor.PackFromVector4(Color.White.ToVector4()); } /// @@ -68,7 +68,7 @@ namespace ImageProcessorCore.Processors Vector4 sourceColor = sourcePixels[x, y].ToVector4(); Vector4 result = Vector4.Lerp(glowColor.ToVector4(), sourceColor, .5f * (distance / maxDistance)); T packed = default(T); - packed.PackVector(result); + packed.PackFromVector4(result); targetPixels[x, y] = packed; } diff --git a/src/ImageProcessorCore/Filters/Processors/InvertProcessor.cs b/src/ImageProcessorCore/Filters/Processors/InvertProcessor.cs index 221dc97ffd..381257e999 100644 --- a/src/ImageProcessorCore/Filters/Processors/InvertProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/InvertProcessor.cs @@ -41,7 +41,7 @@ namespace ImageProcessorCore.Processors Vector3 vector = inverseVector - new Vector3(color.X, color.Y, color.Z); T packed = default(T); - packed.PackVector(new Vector4(vector, color.W)); + packed.PackFromVector4(new Vector4(vector, color.W)); targetPixels[x, y] = packed; } diff --git a/src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs b/src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs index 905849a2e1..6c67270a90 100644 --- a/src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs @@ -23,7 +23,7 @@ namespace ImageProcessorCore.Processors /// public VignetteProcessor() { - this.VignetteColor.PackVector(Color.Black.ToVector4()); + this.VignetteColor.PackFromVector4(Color.Black.ToVector4()); } /// @@ -67,7 +67,7 @@ namespace ImageProcessorCore.Processors Vector4 sourceColor = sourcePixels[x, y].ToVector4(); Vector4 result = Vector4.Lerp(vignetteColor.ToVector4(), sourceColor, 1 - .9f * (distance / maxDistance)); T packed = default(T); - packed.PackVector(result); + packed.PackFromVector4(result); targetPixels[x, y] = packed; } diff --git a/src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs b/src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs index c6704bdb07..50b131bb8d 100644 --- a/src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs @@ -243,7 +243,7 @@ namespace ImageProcessorCore.Formats // Stored in b-> g-> r order. 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; } } @@ -295,7 +295,7 @@ namespace ImageProcessorCore.Formats // Stored in b-> g-> r order. T packed = default(T); - packed.PackBytes(r, g, b, 255); + packed.PackFromBytes(r, g, b, 255); 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. // Stored in b-> g-> r-> a order. 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; } }); @@ -376,7 +376,7 @@ namespace ImageProcessorCore.Formats // Stored in b-> g-> r-> a order. 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; } }); diff --git a/src/ImageProcessorCore/Formats/Gif/GifDecoderCore.cs b/src/ImageProcessorCore/Formats/Gif/GifDecoderCore.cs index f431d3a0a3..f981c0c290 100644 --- a/src/ImageProcessorCore/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageProcessorCore/Formats/Gif/GifDecoderCore.cs @@ -360,7 +360,7 @@ namespace ImageProcessorCore.Formats int indexOffset = index * 3; 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; } diff --git a/src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id b/src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id index de448dbb1c..548cdf74c8 100644 --- a/src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id +++ b/src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id @@ -1 +1 @@ -09cbf92c0d7d3e4659626b60663612836e1e90e7 \ No newline at end of file +adc0f0265d9f43bfcc4b6e12b48eda9c8f48b81a \ No newline at end of file diff --git a/src/ImageProcessorCore/Formats/Png/GrayscaleReader.cs b/src/ImageProcessorCore/Formats/Png/GrayscaleReader.cs index 780f5f6241..cc813a6ebf 100644 --- a/src/ImageProcessorCore/Formats/Png/GrayscaleReader.cs +++ b/src/ImageProcessorCore/Formats/Png/GrayscaleReader.cs @@ -52,7 +52,7 @@ namespace ImageProcessorCore.Formats byte a = newScanline[(x * 2) + 1]; T color = default(T); - color.PackBytes(rgb, rgb, rgb, a); + color.PackFromBytes(rgb, rgb, rgb, a); pixels[offset] = color; } } @@ -64,7 +64,7 @@ namespace ImageProcessorCore.Formats byte rgb = newScanline[x]; T color = default(T); - color.PackBytes(rgb, rgb, rgb, 255); + color.PackFromBytes(rgb, rgb, rgb, 255); pixels[offset] = color; } diff --git a/src/ImageProcessorCore/Formats/Png/PaletteIndexReader.cs b/src/ImageProcessorCore/Formats/Png/PaletteIndexReader.cs index 9fba4f0e21..52d88e022f 100644 --- a/src/ImageProcessorCore/Formats/Png/PaletteIndexReader.cs +++ b/src/ImageProcessorCore/Formats/Png/PaletteIndexReader.cs @@ -66,7 +66,7 @@ namespace ImageProcessorCore.Formats : (byte)255; T color = default(T); - color.PackBytes(r, g, b, a); + color.PackFromBytes(r, g, b, a); pixels[offset] = color; } } @@ -84,7 +84,7 @@ namespace ImageProcessorCore.Formats byte b = this.palette[pixelOffset + 2]; T color = default(T); - color.PackBytes(r, g, b, 255); + color.PackFromBytes(r, g, b, 255); pixels[offset] = color; } } diff --git a/src/ImageProcessorCore/Formats/Png/TrueColorReader.cs b/src/ImageProcessorCore/Formats/Png/TrueColorReader.cs index 07ed958554..86ac7db386 100644 --- a/src/ImageProcessorCore/Formats/Png/TrueColorReader.cs +++ b/src/ImageProcessorCore/Formats/Png/TrueColorReader.cs @@ -53,7 +53,7 @@ namespace ImageProcessorCore.Formats byte a = newScanline[x + 3]; T color = default(T); - color.PackBytes(r, g, b, a); + color.PackFromBytes(r, g, b, a); pixels[offset] = color; } @@ -70,7 +70,7 @@ namespace ImageProcessorCore.Formats byte b = newScanline[pixelOffset + 2]; T color = default(T); - color.PackBytes(r, g, b, 255); + color.PackFromBytes(r, g, b, 255); pixels[offset] = color; } } diff --git a/src/ImageProcessorCore/Quantizers/Octree/OctreeQuantizer.cs b/src/ImageProcessorCore/Quantizers/Octree/OctreeQuantizer.cs index 344a1607e5..3eb3f3d4b8 100644 --- a/src/ImageProcessorCore/Quantizers/Octree/OctreeQuantizer.cs +++ b/src/ImageProcessorCore/Quantizers/Octree/OctreeQuantizer.cs @@ -197,7 +197,7 @@ namespace ImageProcessorCore.Quantizers /// 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 if (this.previousColor.Equals(packed)) { @@ -468,7 +468,7 @@ namespace ImageProcessorCore.Quantizers // And set the color of the palette entry T pixel = default(T); - pixel.PackBytes(r, g, b, 255); + pixel.PackFromBytes(r, g, b, 255); palette.Add(pixel); } else diff --git a/src/ImageProcessorCore/Quantizers/Palette/PaletteQuantizer.cs b/src/ImageProcessorCore/Quantizers/Palette/PaletteQuantizer.cs index 9de4a4dc4a..99c782c4d1 100644 --- a/src/ImageProcessorCore/Quantizers/Palette/PaletteQuantizer.cs +++ b/src/ImageProcessorCore/Quantizers/Palette/PaletteQuantizer.cs @@ -47,7 +47,7 @@ namespace ImageProcessorCore.Quantizers foreach (Color c in constants) { T packed = default(T); - packed.PackVector(c.ToVector4()); + packed.PackFromVector4(c.ToVector4()); safe.Add(packed); } diff --git a/src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs b/src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs index 8b6e72e22a..952039ba45 100644 --- a/src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs +++ b/src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs @@ -745,7 +745,7 @@ namespace ImageProcessorCore.Quantizers byte a = (byte)(Volume(cube[k], this.vma) / weight); T color = default(T); - color.PackBytes(r, g, b, a); + color.PackFromBytes(r, g, b, a); if (color.Equals(default(T))) { diff --git a/src/ImageProcessorCore/Samplers/Processors/CompandingResizeProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/CompandingResizeProcessor.cs index 882a864db3..1790c4a9d6 100644 --- a/src/ImageProcessorCore/Samplers/Processors/CompandingResizeProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/CompandingResizeProcessor.cs @@ -124,7 +124,7 @@ namespace ImageProcessorCore.Processors } T d = default(T); - d.PackVector(destination.Compress()); + d.PackFromVector4(destination.Compress()); firstPassPixels[x, y] = d; } }); @@ -151,7 +151,7 @@ namespace ImageProcessorCore.Processors } T d = default(T); - d.PackVector(destination.Compress()); + d.PackFromVector4(destination.Compress()); targetPixels[x, y] = d; } diff --git a/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs index 191fc0739d..408ca9e544 100644 --- a/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs @@ -123,7 +123,7 @@ namespace ImageProcessorCore.Processors } T d = default(T); - d.PackVector(destination); + d.PackFromVector4(destination); firstPassPixels[x, y] = d; } }); @@ -150,7 +150,7 @@ namespace ImageProcessorCore.Processors } T d = default(T); - d.PackVector(destination); + d.PackFromVector4(destination); targetPixels[x, y] = d; } diff --git a/tests/ImageProcessorCore.Tests/Colors/Class.cs b/tests/ImageProcessorCore.Tests/Colors/ColorTests.cs similarity index 77% rename from tests/ImageProcessorCore.Tests/Colors/Class.cs rename to tests/ImageProcessorCore.Tests/Colors/ColorTests.cs index a93aac5f9b..69ed6ff73d 100644 --- a/tests/ImageProcessorCore.Tests/Colors/Class.cs +++ b/tests/ImageProcessorCore.Tests/Colors/ColorTests.cs @@ -75,23 +75,17 @@ namespace ImageProcessorCore.Tests Assert.Equal(0, color3.B); Assert.Equal(255, color3.A); - //Color color4 = new Color(new Vector3(1, .1f, .133f)); - //Assert.Equal(1, color4.R, 1); - //Assert.Equal(.1f, color4.G, 1); - //Assert.Equal(.133f, color4.B, 3); - //Assert.Equal(1, color4.A, 1); + Color color4 = new Color(new Vector3(1, .1f, .133f)); + Assert.Equal(255, color4.R); + Assert.Equal(Math.Round(.1f * 255), color4.G); + Assert.Equal(Math.Round(.133f * 255), color4.B); + Assert.Equal(255, color4.A); - //Color color5 = new Color(new Vector3(1, .1f, .133f), .5f); - //Assert.Equal(1, color5.R, 1); - //Assert.Equal(.1f, color5.G, 1); - //Assert.Equal(.133f, color5.B, 3); - //Assert.Equal(.5f, color5.A, 1); - - 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); + Color color5 = new Color(new Vector4(1, .1f, .133f, .5f)); + Assert.Equal(255, color5.R); + Assert.Equal(Math.Round(.1f * 255), color5.G); + Assert.Equal(Math.Round(.133f * 255), color5.B); + Assert.Equal(Math.Round(.5f * 255), color5.A); } /// @@ -102,7 +96,7 @@ namespace ImageProcessorCore.Tests { const string First = "FF000000"; Color color = Color.Black; - string second = color.PackedValue().ToString("X"); + string second = color.GetPackedValue().ToString("X"); Assert.Equal(First, second); } }