public void AreNotEqual() { var color1 = new Bgr24(byte.MaxValue, 0, 0); var color2 = new Bgr24(byte.MaxValue, 0, byte.MaxValue); Assert.NotEqual(color1, color2); }
public void ConstructFrom_Bgr24() { var expected = new Rgba64(5140, 9766, 19532, ushort.MaxValue); var source = new Bgr24(20, 38, 76); var actual = new Rgba64(source); Assert.Equal(expected, actual); }
public void Equals_WhenFalse(byte r1, byte g1, byte b1, byte r2, byte g2, byte b2) { var a = new Bgr24(r1, g1, b1); var b = new Bgr24(r2, g2, b2); Assert.False(a.Equals(b)); Assert.False(a.Equals((object)b)); }
public void ToBgr24(ref Bgr24 dest) { var y = PackedValue; dest.R = y; dest.G = y; dest.B = y; }
public void ToBgr24(ref Bgr24 dest) { Vector4 vector = this.ToVector4() * 255F; dest.R = (byte)MathF.Round(vector.X); dest.G = (byte)MathF.Round(vector.Y); dest.B = (byte)MathF.Round(vector.Z); }
public void ToRgba32() { var rgb = new Bgr24(1, 2, 3); var rgba = default(Rgba32); rgb.ToRgba32(ref rgba); Assert.Equal(new Rgba32(1, 2, 3, 255), rgba); }
public void ToBgra32() { var rgb = new Bgr24(1, 2, 3); var bgra = default(Bgra32); rgb.ToBgra32(ref bgra); Assert.Equal(new Bgra32(1, 2, 3, 255), bgra); }
public unsafe void ByteLayoutIsSequentialBgr() { var color = new Bgr24(1, 2, 3); byte *ptr = (byte *)&color; Assert.Equal(3, ptr[0]); Assert.Equal(2, ptr[1]); Assert.Equal(1, ptr[2]); }
public void Equals_WhenTrue(byte r, byte g, byte b) { var x = new Bgr24(r, g, b); var y = new Bgr24(r, g, b); Assert.True(x.Equals(y)); Assert.True(x.Equals((object)y)); Assert.Equal(x.GetHashCode(), y.GetHashCode()); }
public void ToRgb24() { var rgb = new Bgr24(1, 2, 3); var dest = default(Rgb24); rgb.ToRgb24(ref dest); Assert.Equal(new Rgb24(1, 2, 3), dest); }
public void ToBgr24() { var rgb = new Bgr24(1, 2, 3); var bgr = default(Bgr24); rgb.ToBgr24(ref bgr); Assert.Equal(new Bgr24(1, 2, 3), bgr); }
public void Bgr24() { var source = new Bgr24(1, 22, 231); // Act: var color = new Color(source); // Assert: Bgr24 data = color; Assert.Equal(source, data); }
public void Bgr24() { var source = new Bgr24(1, 22, 231); // Act: Color color = source; // Assert: Bgr24 data = color.ToPixel <Bgr24>(); Assert.Equal(source, data); }
public void ToBgr24_Retval() { // arrange var source = new Rgba64(5140, 9766, 19532, 29555); var expected = new Bgr24(20, 38, 76); // act var actual = source.ToBgr24(); // assert Assert.Equal(expected, actual); }
public void NormalizedByte4_ToBgr24() { // arrange var short4 = new NormalizedByte4(0.1f, -0.3f, 0.5f, -0.7f); var actual = default(Bgr24); var expected = new Bgr24(141, 90, 192); // act short4.ToBgr24(ref actual); // assert Assert.Equal(expected, actual); }
public void Short2_ToBgr24() { // arrange var short2 = new Short2(127.5f, -5.3f); var actual = default(Bgr24); var expected = new Bgr24(128, 127, 0); // act short2.ToBgr24(ref actual); // assert Assert.Equal(expected, actual); }
public void NormalizedShort2_ToBgr24() { // arrange var short2 = new NormalizedShort2(0.1f, -0.3f); var actual = default(Bgr24); var expected = new Bgr24(141, 90, 0); // act short2.ToBgr24(ref actual); // assert Assert.Equal(expected, actual); }
public void Rgba1010102_ToBgr24() { // arrange var rgba = new Rgba1010102(0.1f, -0.3f, 0.5f, -0.7f); var actual = default(Bgr24); var expected = new Bgr24(25, 0, 128); // act rgba.ToBgr24(ref actual); // assert Assert.Equal(expected, actual); }
public void Rg32_ToBgr24() { // arrange var rg32 = new Rg32(0.1f, -0.3f); var actual = default(Bgr24); var expected = new Bgr24(25, 0, 0); // act rg32.ToBgr24(ref actual); // assert Assert.Equal(expected, actual); }
public void Rgba64_ToBgr24() { // arrange var rgba64 = new Rgba64(0.08f, 0.15f, 0.30f, 0.45f); var actual = default(Bgr24); var expected = new Bgr24(20, 38, 76); // act rgba64.ToBgr24(ref actual); // assert Assert.Equal(expected, actual); }
public void Bgr565_ToBgr24() { // arrange var bgra = new Bgr565(0.1F, -0.3F, 0.5F); var actual = default(Bgr24); var expected = new Bgr24(25, 0, 132); // act bgra.ToBgr24(ref actual); // assert Assert.Equal(expected, actual); }
public void HalfSingle_ToBgr24() { // arrange var halfVector = new HalfSingle(.5F); var actual = default(Bgr24); var expected = new Bgr24(128, 0, 0); // act halfVector.ToBgr24(ref actual); // assert Assert.Equal(expected, actual); }
public void Argb32_ToBgr24() { // arrange var argb = new Argb32(+0.1f, -0.3f, +0.5f, -0.7f); var actual = default(Bgr24); var expected = new Bgr24(0x1a, 0, 0x80); // act argb.ToBgr24(ref actual); // assert Assert.Equal(expected, actual); }
public void HalfVector4_ToBgr24() { // arrange var halfVector = new HalfVector4(.25F, .5F, .75F, 1F); var actual = default(Bgr24); var expected = new Bgr24(64, 128, 191); // act halfVector.ToBgr24(ref actual); // assert Assert.Equal(expected, actual); }
public void Byte4_ToBgr24() { // arrange var byte4 = new Byte4(127.5f, -12.3f, 0.5f, -0.7f); var actual = default(Bgr24); var expected = new Bgr24(128, 0, 0); // act byte4.ToBgr24(ref actual); // assert Assert.Equal(expected, actual); }
public void Bgra4444_ToBgr24() { // arrange var bgra = new Bgra4444(0.1f, -0.3f, 0.5f, -0.7f); var actual = default(Bgr24); var expected = new Bgr24(34, 0, 136); // act bgra.ToBgr24(ref actual); // assert Assert.Equal(expected, actual); }
public void Short4_ToBgr24() { // arrange var shortValue = new Short4(11547, 12653, 29623, 193); var actual = default(Bgr24); var expected = new Bgr24(172, 177, 243); // act shortValue.ToBgr24(ref actual); // assert Assert.Equal(expected, actual); }
public void Alpha8_PackFromScaledVector4_ToBgr24() { // arrange Bgr24 actual = default; Alpha8 alpha = default; var expected = new Bgr24(0, 0, 0); Vector4 scaled = new Alpha8(.5F).ToScaledVector4(); // act alpha.PackFromScaledVector4(scaled); alpha.ToBgr24(ref actual); // assert Assert.Equal(expected, actual); }
static void Main(string[] args) { Parser.Default.ParseArguments <Options>(args).WithParsed(o => { // TODO: Refactor everything here and split into functions using var reader = File.OpenText(o.ScenePath); var yaml = reader.ReadToEnd(); var scene = Serialization.ReadScene(yaml); if (o.Height.HasValue) { scene.Camera.PixelHeight = o.Height.Value; } if (o.Ratio.HasValue) { scene.Camera.Ratio = o.Ratio.Value; } var sw = Stopwatch.StartNew(); var done = 0; var render = scene.Camera.Render(scene, o.Samples, (_, _, _, _, _, count) => { Interlocked.Increment(ref done); var p = Volatile.Read(ref done) / (float)count; Console.Write($"{p:P1}\r"); }); sw.Stop(); Console.WriteLine($"{sw.Elapsed.TotalSeconds:N3} seconds"); using var bitmap = new Image <Bgr24>(scene.Camera.PixelWidth, scene.Camera.PixelHeight); for (var y = 0; y < bitmap.Height; y++) { var pixelRowSpan = bitmap.GetPixelRowSpan(y); for (var x = 0; x < bitmap.Width; x++) { var c = render[y, x]; pixelRowSpan[x] = new Bgr24(c.R, c.G, c.B); } } bitmap.Save(o.OutputPath); Console.WriteLine("done! "); }); }
public void SetImageExact(int keyIndex, Image <Bgr24> image) { int key = ValidateKeyIndex(keyIndex); if (image.Height == IconSize && image.Width == IconSize) { var page1Buf = new byte[NumFirstPagePixels * 3]; var page2Buf = new byte[NumSecondPagePixels * 3]; int pixelOffset = 0; int bufOffset = 0; for (; pixelOffset < NumFirstPagePixels; pixelOffset++) { // reverse the image. int x = image.Width - 1 - (pixelOffset % image.Width); int y = pixelOffset / image.Width; Bgr24 pixel = image[x, y]; page1Buf[bufOffset] = pixel.B; bufOffset++; page1Buf[bufOffset] = pixel.G; bufOffset++; page1Buf[bufOffset] = pixel.R; bufOffset++; } bufOffset = 0; for (; pixelOffset - NumFirstPagePixels < NumSecondPagePixels; pixelOffset++) { int x = image.Width - 1 - (pixelOffset % image.Width); int y = pixelOffset / image.Width; Bgr24 pixel = image[x, y]; page2Buf[bufOffset] = pixel.B; bufOffset++; page2Buf[bufOffset] = pixel.G; bufOffset++; page2Buf[bufOffset] = pixel.R; bufOffset++; } WritePage1(key, page1Buf); WritePage2(key, page2Buf); } }