mirror of
https://github.com/DarthAffe/HPPH.git
synced 2025-12-12 13:28:37 +00:00
Merge pull request #5 from DarthAffe/ConversionFix
Fixed potential error in in-place conversion and improved tests to co…
This commit is contained in:
commit
32664a2971
@ -748,7 +748,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void IndexerWrongXBig()
|
||||
{
|
||||
Image<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -756,7 +756,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void IndexerWrongYBig()
|
||||
{
|
||||
Image<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -764,7 +764,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void IndexerWrongXSmall()
|
||||
{
|
||||
Image<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -772,7 +772,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void IndexerWrongYSmall()
|
||||
{
|
||||
Image<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -780,7 +780,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageWrongX()
|
||||
{
|
||||
Image<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -788,7 +788,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageWrongY()
|
||||
{
|
||||
Image<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -796,7 +796,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageWrongWidth()
|
||||
{
|
||||
Image<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -804,7 +804,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageWrongHeight()
|
||||
{
|
||||
Image<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -812,7 +812,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageInvalidSizeWidth()
|
||||
{
|
||||
Image<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -820,7 +820,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageInvalidSizeHeight()
|
||||
{
|
||||
Image<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -828,7 +828,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageInterfaceWrongX()
|
||||
{
|
||||
IImage image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -836,7 +836,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageInterfaceWrongY()
|
||||
{
|
||||
IImage image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -844,7 +844,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageInterfaceWrongWidth()
|
||||
{
|
||||
IImage image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -852,7 +852,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageInterfaceWrongHeight()
|
||||
{
|
||||
IImage image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -860,7 +860,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageInterfaceInvalidSizeWidth()
|
||||
{
|
||||
IImage image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -868,7 +868,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageInterfaceInvalidSizeHeight()
|
||||
{
|
||||
IImage image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -876,7 +876,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void ColumnsIndexerToBig()
|
||||
{
|
||||
IImage image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -884,7 +884,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void ColumnsIndexerToSmall()
|
||||
{
|
||||
IImage image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -892,7 +892,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void RowsIndexerToBig()
|
||||
{
|
||||
IImage image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -900,7 +900,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void RowsIndexerToSmall()
|
||||
{
|
||||
IImage image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -908,7 +908,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void ColumnIndexerToBig()
|
||||
{
|
||||
IImage image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -916,7 +916,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void ColumnIndexerToSmall()
|
||||
{
|
||||
IImage image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -924,7 +924,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void RowIndexerToBig()
|
||||
{
|
||||
IImage image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
@ -932,7 +932,7 @@ public class ImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void RowIndexerToSmall()
|
||||
{
|
||||
IImage image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20);
|
||||
|
||||
@ -296,7 +296,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void IndexerWrongXBig()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -304,7 +304,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void IndexerWrongYBig()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -312,7 +312,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void IndexerWrongXSmall()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -320,7 +320,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void IndexerWrongYSmall()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -328,7 +328,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageWrongX()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -336,7 +336,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageWrongY()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -344,7 +344,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageWrongWidth()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -352,7 +352,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageWrongHeight()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -360,7 +360,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageInvalidSizeWidth()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -368,7 +368,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void SubImageInvalidSizeHeight()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -376,7 +376,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void ColumnsIndexerToBig()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -384,7 +384,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void ColumnsIndexerToSmall()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -392,7 +392,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void RowsIndexerToBig()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -400,7 +400,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void RowsIndexerToSmall()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -408,7 +408,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void ColumnIndexerToBig()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -416,7 +416,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void ColumnIndexerToSmall()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -424,7 +424,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void RowIndexerToBig()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
@ -432,7 +432,7 @@ public class RefImageTest
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void RowIndexerToSmall()
|
||||
{
|
||||
RefImage<ColorRGB> image = TestDataHelper.CreateTestImage<ColorRGB>(10, 20).AsRefImage();
|
||||
|
||||
@ -33,6 +33,12 @@ public class ConvertTests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IImage<ColorBGR> converted = TestDataHelper.CreateTestImage<ColorRGB>(1920, 1080).ConvertTo<ColorBGR>();
|
||||
|
||||
for (int y = 0; y < converted.Height; y++)
|
||||
for (int x = 0; x < converted.Width; x++)
|
||||
Assert.AreEqual(TestDataHelper.GetColorFromLocation<ColorBGR>(x, y), converted[x, y], $"Wrong color at x: {x}, y: {y}");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -63,6 +69,12 @@ public class ConvertTests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IImage<ColorARGB> converted = TestDataHelper.CreateTestImage<ColorRGBA>(1920, 1080).ConvertTo<ColorARGB>();
|
||||
|
||||
for (int y = 0; y < converted.Height; y++)
|
||||
for (int x = 0; x < converted.Width; x++)
|
||||
Assert.AreEqual(TestDataHelper.GetColorFromLocation<ColorARGB>(x, y), converted[x, y], $"Wrong color at x: {x}, y: {y}");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -93,6 +105,12 @@ public class ConvertTests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IImage<ColorBGRA> converted = TestDataHelper.CreateTestImage<ColorRGBA>(1920, 1080).ConvertTo<ColorBGRA>();
|
||||
|
||||
for (int y = 0; y < converted.Height; y++)
|
||||
for (int x = 0; x < converted.Width; x++)
|
||||
Assert.AreEqual(TestDataHelper.GetColorFromLocation<ColorBGRA>(x, y), converted[x, y], $"Wrong color at x: {x}, y: {y}");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -123,6 +141,12 @@ public class ConvertTests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IImage<ColorRGB> converted = TestDataHelper.CreateTestImage<ColorRGBA>(1920, 1080).ConvertTo<ColorRGB>();
|
||||
|
||||
for (int y = 0; y < converted.Height; y++)
|
||||
for (int x = 0; x < converted.Width; x++)
|
||||
Assert.AreEqual(TestDataHelper.GetColorFromLocation<ColorRGB>(x, y), converted[x, y], $"Wrong color at x: {x}, y: {y}");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -153,6 +177,12 @@ public class ConvertTests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IImage<ColorBGR> converted = TestDataHelper.CreateTestImage<ColorRGBA>(1920, 1080).ConvertTo<ColorBGR>();
|
||||
|
||||
for (int y = 0; y < converted.Height; y++)
|
||||
for (int x = 0; x < converted.Width; x++)
|
||||
Assert.AreEqual(TestDataHelper.GetColorFromLocation<ColorBGR>(x, y), converted[x, y], $"Wrong color at x: {x}, y: {y}");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -183,6 +213,20 @@ public class ConvertTests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IImage<ColorRGBA> converted = TestDataHelper.CreateTestImage<ColorRGB>(1920, 1080).ConvertTo<ColorRGBA>();
|
||||
|
||||
for (int y = 0; y < converted.Height; y++)
|
||||
for (int x = 0; x < converted.Width; x++)
|
||||
{
|
||||
ColorABGR refColor = TestDataHelper.GetColorFromLocation<ColorABGR>(x, y);
|
||||
ColorRGBA color = converted[x, y];
|
||||
|
||||
Assert.AreEqual(255, color.A, $"Wrong A at x: {x}, y: {y}");
|
||||
Assert.AreEqual(refColor.R, color.R, $"Wrong R at x: {x}, y: {y}");
|
||||
Assert.AreEqual(refColor.G, color.G, $"Wrong G at x: {x}, y: {y}");
|
||||
Assert.AreEqual(refColor.B, color.B, $"Wrong B at x: {x}, y: {y}");
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -213,6 +257,20 @@ public class ConvertTests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IImage<ColorARGB> converted = TestDataHelper.CreateTestImage<ColorRGB>(1920, 1080).ConvertTo<ColorARGB>();
|
||||
|
||||
for (int y = 0; y < converted.Height; y++)
|
||||
for (int x = 0; x < converted.Width; x++)
|
||||
{
|
||||
ColorABGR refColor = TestDataHelper.GetColorFromLocation<ColorABGR>(x, y);
|
||||
ColorARGB color = converted[x, y];
|
||||
|
||||
Assert.AreEqual(255, color.A, $"Wrong A at x: {x}, y: {y}");
|
||||
Assert.AreEqual(refColor.R, color.R, $"Wrong R at x: {x}, y: {y}");
|
||||
Assert.AreEqual(refColor.G, color.G, $"Wrong G at x: {x}, y: {y}");
|
||||
Assert.AreEqual(refColor.B, color.B, $"Wrong B at x: {x}, y: {y}");
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -243,6 +301,20 @@ public class ConvertTests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IImage<ColorBGRA> converted = TestDataHelper.CreateTestImage<ColorRGB>(1920, 1080).ConvertTo<ColorBGRA>();
|
||||
|
||||
for (int y = 0; y < converted.Height; y++)
|
||||
for (int x = 0; x < converted.Width; x++)
|
||||
{
|
||||
ColorABGR refColor = TestDataHelper.GetColorFromLocation<ColorABGR>(x, y);
|
||||
ColorBGRA color = converted[x, y];
|
||||
|
||||
Assert.AreEqual(255, color.A, $"Wrong A at x: {x}, y: {y}");
|
||||
Assert.AreEqual(refColor.R, color.R, $"Wrong R at x: {x}, y: {y}");
|
||||
Assert.AreEqual(refColor.G, color.G, $"Wrong G at x: {x}, y: {y}");
|
||||
Assert.AreEqual(refColor.B, color.B, $"Wrong B at x: {x}, y: {y}");
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -273,6 +345,20 @@ public class ConvertTests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IImage<ColorABGR> converted = TestDataHelper.CreateTestImage<ColorRGB>(1920, 1080).ConvertTo<ColorABGR>();
|
||||
|
||||
for (int y = 0; y < converted.Height; y++)
|
||||
for (int x = 0; x < converted.Width; x++)
|
||||
{
|
||||
ColorABGR refColor = TestDataHelper.GetColorFromLocation<ColorABGR>(x, y);
|
||||
ColorABGR color = converted[x, y];
|
||||
|
||||
Assert.AreEqual(255, color.A, $"Wrong A at x: {x}, y: {y}");
|
||||
Assert.AreEqual(refColor.R, color.R, $"Wrong R at x: {x}, y: {y}");
|
||||
Assert.AreEqual(refColor.G, color.G, $"Wrong G at x: {x}, y: {y}");
|
||||
Assert.AreEqual(refColor.B, color.B, $"Wrong B at x: {x}, y: {y}");
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -303,5 +389,11 @@ public class ConvertTests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IImage<ColorBGR> converted = TestDataHelper.CreateTestImage<ColorRGB>(1920, 1080).ConvertTo<ColorBGR>();
|
||||
|
||||
for (int y = 0; y < converted.Height; y++)
|
||||
for (int x = 0; x < converted.Width; x++)
|
||||
Assert.AreEqual(TestDataHelper.GetColorFromLocation<ColorBGR>(x, y), converted[x, y], $"Wrong color at x: {x}, y: {y}");
|
||||
}
|
||||
}
|
||||
@ -16,6 +16,14 @@ public class SystemDrawingTests
|
||||
IImage image2 = bitmap.ToImage();
|
||||
|
||||
Assert.AreEqual(IColorFormat.BGR, image2.ColorFormat);
|
||||
for (int y = 0; y < image.Height; y++)
|
||||
for (int x = 0; x < image.Width; x++)
|
||||
{
|
||||
Assert.AreEqual(image[x, y].A, image2[x, y].A, $"{x}-{y}");
|
||||
Assert.AreEqual(image[x, y].R, image2[x, y].R, $"{x}-{y}");
|
||||
Assert.AreEqual(image[x, y].G, image2[x, y].G, $"{x}-{y}");
|
||||
Assert.AreEqual(image[x, y].B, image2[x, y].B, $"{x}-{y}");
|
||||
}
|
||||
|
||||
image2 = image2.ConvertTo<ColorRGB>();
|
||||
|
||||
@ -30,6 +38,14 @@ public class SystemDrawingTests
|
||||
IImage image2 = bitmap.ToImage();
|
||||
|
||||
Assert.AreEqual(IColorFormat.BGRA, image2.ColorFormat);
|
||||
for (int y = 0; y < image.Height; y++)
|
||||
for (int x = 0; x < image.Width; x++)
|
||||
{
|
||||
Assert.AreEqual(image[x, y].A, image2[x, y].A);
|
||||
Assert.AreEqual(image[x, y].R, image2[x, y].R);
|
||||
Assert.AreEqual(image[x, y].G, image2[x, y].G);
|
||||
Assert.AreEqual(image[x, y].B, image2[x, y].B);
|
||||
}
|
||||
|
||||
image2 = image2.ConvertTo<ColorRGBA>();
|
||||
|
||||
|
||||
@ -174,12 +174,14 @@ public static unsafe partial class PixelHelper
|
||||
tar += bytesPerVector;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[missingElements * BPP];
|
||||
for (int i = 0; i < missingElements; i++)
|
||||
{
|
||||
tar[(i * BPP) + 0] = src[(i * BPP) + maskVector[0]];
|
||||
tar[(i * BPP) + 1] = src[(i * BPP) + maskVector[1]];
|
||||
tar[(i * BPP) + 2] = src[(i * BPP) + maskVector[2]];
|
||||
buffer[(i * BPP) + 0] = src[(i * BPP) + maskVector[0]];
|
||||
buffer[(i * BPP) + 1] = src[(i * BPP) + maskVector[1]];
|
||||
buffer[(i * BPP) + 2] = src[(i * BPP) + maskVector[2]];
|
||||
}
|
||||
buffer.CopyTo(new Span<byte>(tar, buffer.Length));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -191,12 +193,14 @@ public static unsafe partial class PixelHelper
|
||||
byte* missingSrc = sourcePtr + (batches * batchSize * BPP);
|
||||
byte* missingTar = targetPtr + (batches * batchSize * BPP);
|
||||
|
||||
Span<byte> buffer = stackalloc byte[missing * BPP];
|
||||
for (int i = 0; i < missing; i++)
|
||||
{
|
||||
missingTar[(i * BPP) + 0] = missingSrc[(i * BPP) + maskVector[0]];
|
||||
missingTar[(i * BPP) + 1] = missingSrc[(i * BPP) + maskVector[1]];
|
||||
missingTar[(i * BPP) + 2] = missingSrc[(i * BPP) + maskVector[2]];
|
||||
buffer[(i * BPP) + 0] = missingSrc[(i * BPP) + maskVector[0]];
|
||||
buffer[(i * BPP) + 1] = missingSrc[(i * BPP) + maskVector[1]];
|
||||
buffer[(i * BPP) + 2] = missingSrc[(i * BPP) + maskVector[2]];
|
||||
}
|
||||
buffer.CopyTo(new Span<byte>(missingTar, buffer.Length));
|
||||
}
|
||||
|
||||
void Process(int index)
|
||||
@ -217,12 +221,14 @@ public static unsafe partial class PixelHelper
|
||||
tar += bytesPerVector;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[missingElements * BPP];
|
||||
for (int i = 0; i < missingElements; i++)
|
||||
{
|
||||
tar[(i * BPP) + 0] = src[(i * BPP) + maskVector[0]];
|
||||
tar[(i * BPP) + 1] = src[(i * BPP) + maskVector[1]];
|
||||
tar[(i * BPP) + 2] = src[(i * BPP) + maskVector[2]];
|
||||
buffer[(i * BPP) + 0] = src[(i * BPP) + maskVector[0]];
|
||||
buffer[(i * BPP) + 1] = src[(i * BPP) + maskVector[1]];
|
||||
buffer[(i * BPP) + 2] = src[(i * BPP) + maskVector[2]];
|
||||
}
|
||||
buffer.CopyTo(new Span<byte>(tar, buffer.Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -292,13 +298,15 @@ public static unsafe partial class PixelHelper
|
||||
tar += bytesPerVector;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[missingElements * BPP];
|
||||
for (int i = 0; i < missingElements; i++)
|
||||
{
|
||||
tar[(i * BPP) + 0] = src[(i * BPP) + maskVector[0]];
|
||||
tar[(i * BPP) + 1] = src[(i * BPP) + maskVector[1]];
|
||||
tar[(i * BPP) + 2] = src[(i * BPP) + maskVector[2]];
|
||||
tar[(i * BPP) + 3] = src[(i * BPP) + maskVector[3]];
|
||||
buffer[(i * BPP) + 0] = src[(i * BPP) + maskVector[0]];
|
||||
buffer[(i * BPP) + 1] = src[(i * BPP) + maskVector[1]];
|
||||
buffer[(i * BPP) + 2] = src[(i * BPP) + maskVector[2]];
|
||||
buffer[(i * BPP) + 3] = src[(i * BPP) + maskVector[3]];
|
||||
}
|
||||
buffer.CopyTo(new Span<byte>(tar, buffer.Length));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -310,13 +318,15 @@ public static unsafe partial class PixelHelper
|
||||
byte* missingSrc = sourcePtr + (batches * batchSize * BPP);
|
||||
byte* missingTar = targetPtr + (batches * batchSize * BPP);
|
||||
|
||||
Span<byte> buffer = stackalloc byte[missing * BPP];
|
||||
for (int i = 0; i < missing; i++)
|
||||
{
|
||||
missingTar[(i * BPP) + 0] = missingSrc[(i * BPP) + maskVector[0]];
|
||||
missingTar[(i * BPP) + 1] = missingSrc[(i * BPP) + maskVector[1]];
|
||||
missingTar[(i * BPP) + 2] = missingSrc[(i * BPP) + maskVector[2]];
|
||||
missingTar[(i * BPP) + 3] = missingSrc[(i * BPP) + maskVector[3]];
|
||||
buffer[(i * BPP) + 0] = missingSrc[(i * BPP) + maskVector[0]];
|
||||
buffer[(i * BPP) + 1] = missingSrc[(i * BPP) + maskVector[1]];
|
||||
buffer[(i * BPP) + 2] = missingSrc[(i * BPP) + maskVector[2]];
|
||||
buffer[(i * BPP) + 3] = missingSrc[(i * BPP) + maskVector[3]];
|
||||
}
|
||||
buffer.CopyTo(new Span<byte>(missingTar, buffer.Length));
|
||||
}
|
||||
|
||||
void Process(int index)
|
||||
@ -337,18 +347,20 @@ public static unsafe partial class PixelHelper
|
||||
tar += bytesPerVector;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[missingElements * BPP];
|
||||
for (int i = 0; i < missingElements; i++)
|
||||
{
|
||||
tar[(i * BPP) + 0] = src[(i * BPP) + maskVector[0]];
|
||||
tar[(i * BPP) + 1] = src[(i * BPP) + maskVector[1]];
|
||||
tar[(i * BPP) + 2] = src[(i * BPP) + maskVector[2]];
|
||||
tar[(i * BPP) + 3] = src[(i * BPP) + maskVector[3]];
|
||||
buffer[(i * BPP) + 0] = src[(i * BPP) + maskVector[0]];
|
||||
buffer[(i * BPP) + 1] = src[(i * BPP) + maskVector[1]];
|
||||
buffer[(i * BPP) + 2] = src[(i * BPP) + maskVector[2]];
|
||||
buffer[(i * BPP) + 3] = src[(i * BPP) + maskVector[3]];
|
||||
}
|
||||
buffer.CopyTo(new Span<byte>(tar, buffer.Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void ConvertWiden3To4Bytes(ReadOnlySpan<byte> source, Span<byte> target, IColorFormat sourceFormat, IColorFormat targetFormat)
|
||||
{
|
||||
const int SOURCE_BPP = 3;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user