diff --git a/src/ImageProcessorCore/PackedVector/Bgra32.cs b/src/ImageProcessorCore/PackedVector/Bgra32.cs index fc6a788b0..5fdf24e17 100644 --- a/src/ImageProcessorCore/PackedVector/Bgra32.cs +++ b/src/ImageProcessorCore/PackedVector/Bgra32.cs @@ -11,7 +11,7 @@ namespace ImageProcessorCore /// /// Packed vector type containing four 8-bit unsigned normalized values ranging from 0 to 1. /// - public struct Bgra32 : IPackedVector, IEquatable + public struct Bgra32 : IPackedVector, IEquatable { /// /// Initializes a new instance of the struct. @@ -41,6 +41,38 @@ namespace ImageProcessorCore /// public uint PackedValue { get; set; } + // The maths are wrong here I just wanted to test the performance to see if the + // issues are caused by the Vector transform or something else. + public void Add(IPackedVector value) + { + + } + + public void Subtract(IPackedVector value) + { + + } + + public void Multiply(IPackedVector value) + { + + } + + public void Multiply(float value) + { + + } + + public void Divide(IPackedVector value) + { + + } + + public void Divide(float value) + { + + } + /// /// Compares two objects for equality. /// diff --git a/src/ImageProcessorCore/PackedVector/IPackedVector.cs b/src/ImageProcessorCore/PackedVector/IPackedVector.cs index 7022e4d9d..e7533a0dd 100644 --- a/src/ImageProcessorCore/PackedVector/IPackedVector.cs +++ b/src/ImageProcessorCore/PackedVector/IPackedVector.cs @@ -29,6 +29,18 @@ namespace ImageProcessorCore /// public interface IPackedVector { + void Add(IPackedVector value); + + void Subtract(IPackedVector value); + + void Multiply(IPackedVector value); + + void Multiply(float value); + + void Divide(IPackedVector value); + + void Divide(float value); + /// /// Sets the packed representation from a . /// diff --git a/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs index 67d20a564..15d202ef4 100644 --- a/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs @@ -153,27 +153,29 @@ namespace ImageProcessorCore.Processors //} //firstPassPixels[x, y] = destination; - Vector4 destination = new Vector4(); + T destination = new T(); for (int i = 0; i < sum; i++) { Weight xw = horizontalValues[i]; int originX = xw.Index; - Vector4 sourceColor = sourcePixels[originX, y].ToVector4(); + T sourceColor = sourcePixels[originX, y]; //Color sourceColor = compand // ? Color.Expand(sourcePixels[originX, y]) // : sourcePixels[originX, y]; - destination += sourceColor * xw.Value; + //sourceColor.Multiply(xw.Value); + //destination.Add(sourceColor); + //destination += sourceColor * xw.Value; } //if (compand) //{ // destination = Color.Compress(destination); //} - T packed = new T(); - packed.PackVector(destination); + //T packed = new T(); + //packed.PackVector(destination); - firstPassPixels[x, y] = packed; + firstPassPixels[x, y] = destination; } } }); @@ -194,7 +196,7 @@ namespace ImageProcessorCore.Processors for (int x = 0; x < width; x++) { // Destination color components - Vector4 destination = new Vector4(); + T destination = new T(); for (int i = 0; i < sum; i++) { @@ -203,8 +205,11 @@ namespace ImageProcessorCore.Processors //Color sourceColor = compand // ? Color.Expand(firstPassPixels[x, originY]) // : firstPassPixels[x, originY]; - Vector4 sourceColor = firstPassPixels[x, originY].ToVector4(); - destination += sourceColor * yw.Value; + //Vector4 sourceColor = firstPassPixels[x, originY].ToVector4(); + //destination += sourceColor * yw.Value; + T sourceColor = firstPassPixels[x, originY]; + //sourceColor.Multiply(yw.Value); + //destination.Add(sourceColor); } //if (compand) @@ -212,10 +217,10 @@ namespace ImageProcessorCore.Processors // destination = Color.Compress(destination); //} - T packed = new T(); - packed.PackVector(destination); + //T packed = new T(); + //packed.PackVector(destination); - targetPixels[x, y] = packed; + targetPixels[x, y] = destination; } }