public void NormalizedByte4() { // Test PackedValue Assert.Equal((uint)0x0, new NormalizedByte4(Vector4.Zero).PackedValue); Assert.Equal((uint)0x7F7F7F7F, new NormalizedByte4(Vector4.One).PackedValue); Assert.Equal(0x81818181, new NormalizedByte4(-Vector4.One).PackedValue); // Test ToVector4 Assert.True(Equal(Vector4.One, new NormalizedByte4(Vector4.One).ToVector4())); Assert.True(Equal(Vector4.Zero, new NormalizedByte4(Vector4.Zero).ToVector4())); Assert.True(Equal(-Vector4.One, new NormalizedByte4(-Vector4.One).ToVector4())); Assert.True(Equal(Vector4.One, new NormalizedByte4(Vector4.One * 1234.0f).ToVector4())); Assert.True(Equal(-Vector4.One, new NormalizedByte4(Vector4.One * -1234.0f).ToVector4())); // Test Ordering float x = 0.1f; float y = -0.3f; float z = 0.5f; float w = -0.7f; Assert.Equal(0xA740DA0D, new NormalizedByte4(x, y, z, w).PackedValue); var n = new NormalizedByte4(); n.PackFromRgba32(new Rgba32(141, 90, 192, 39)); Assert.Equal(0xA740DA0D, n.PackedValue); Assert.Equal((uint)958796544, new NormalizedByte4(0.0008f, 0.15f, 0.30f, 0.45f).PackedValue); var rgb = default(Rgb24); var rgba = default(Rgba32); var bgr = default(Bgr24); var bgra = default(Bgra32); new NormalizedByte4(x, y, z, w).ToRgb24(ref rgb); Assert.Equal(rgb, new Rgb24(141, 90, 192)); new NormalizedByte4(x, y, z, w).ToRgba32(ref rgba); Assert.Equal(rgba, new Rgba32(141, 90, 192, 39)); new NormalizedByte4(x, y, z, w).ToBgr24(ref bgr); Assert.Equal(bgr, new Bgr24(141, 90, 192)); new NormalizedByte4(x, y, z, w).ToBgra32(ref bgra); Assert.Equal(bgra, new Bgra32(141, 90, 192, 39)); // http://community.monogame.net/t/normalizedbyte4-texture2d-gives-different-results-from-xna/8012/8 var r = new NormalizedByte4(); r.PackFromRgba32(new Rgba32(9, 115, 202, 127)); r.ToRgba32(ref rgba); Assert.Equal(rgba, new Rgba32(9, 115, 202, 127)); r.PackedValue = 0xff4af389; r.ToRgba32(ref rgba); Assert.Equal(rgba, new Rgba32(9, 115, 202, 127)); }
public void NormalizedByte4_ToRgba32() { // arrange var byte4 = new NormalizedByte4(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); var expected = new Rgba32(Vector4.One); var actual = default(Rgba32); // act byte4.ToRgba32(ref actual); Assert.Equal(expected, actual); }
public void NormalizedByte4_ToRgba32() { // arrange var short4 = new NormalizedByte4(0.1f, -0.3f, 0.5f, -0.7f); var actual = default(Rgba32); var expected = new Rgba32(141, 90, 192, 39); // act short4.ToRgba32(ref actual); // assert Assert.Equal(expected, actual); }