@ -15,7 +15,7 @@ namespace ImageSharp.Tests.Colors
/// </summary>
/// <remarks>
/// The "ToVector4" tests should now be covered in <see cref="ColorConstructorTests"/>
/// and at some point they can be safely removed from here.
/// and at some point they can be safely removed from here.
/// </remarks>
public class PackedPixelTests
{
@ -47,16 +47,16 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new Alpha8 ( . 5F ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new Alpha8 ( . 5F ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 0 , 0 , 0 } ) ;
new Alpha8 ( . 5F ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new Alpha8 ( . 5F ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 0 , 0 , 0 , 1 2 8 } ) ;
new Alpha8 ( . 5F ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new Alpha8 ( . 5F ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 0 , 0 , 0 } ) ;
new Alpha8 ( . 5F ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new Alpha8 ( . 5F ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 0 , 0 , 0 , 1 2 8 } ) ;
}
@ -92,16 +92,16 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
argb . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
argb . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 0x1a , 0 , 0x80 } ) ;
argb . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
argb . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 0x1a , 0 , 0x80 , 0 } ) ;
argb . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
argb . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 0x80 , 0 , 0x1a } ) ;
argb . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
argb . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 0x80 , 0 , 0x1a , 0 } ) ;
}
@ -133,23 +133,22 @@ namespace ImageSharp.Tests.Colors
float z = 0.5F ;
Assert . Equal ( 6 1 6 0 , new Bgr565 ( x , y , z ) . PackedValue ) ;
// Test ordering
byte [ ] rgb = new byte [ 3 ] ;
byte [ ] rgba = new byte [ 4 ] ;
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new Bgr565 ( x , y , z ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new Bgr565 ( x , y , z ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 2 5 , 0 , 1 3 2 } ) ;
new Bgr565 ( x , y , z ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new Bgr565 ( x , y , z ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 2 5 , 0 , 1 3 2 , 2 5 5 } ) ;
new Bgr565 ( x , y , z ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new Bgr565 ( x , y , z ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 1 3 2 , 0 , 2 5 } ) ;
new Bgr565 ( x , y , z ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new Bgr565 ( x , y , z ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 1 3 2 , 0 , 2 5 , 2 5 5 } ) ;
}
@ -190,16 +189,16 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new Bgra4444 ( x , y , z , w ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new Bgra4444 ( x , y , z , w ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 3 4 , 0 , 1 3 6 } ) ;
new Bgra4444 ( x , y , z , w ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new Bgra4444 ( x , y , z , w ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 3 4 , 0 , 1 3 6 , 0 } ) ;
new Bgra4444 ( x , y , z , w ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new Bgra4444 ( x , y , z , w ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 1 3 6 , 0 , 3 4 } ) ;
new Bgra4444 ( x , y , z , w ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new Bgra4444 ( x , y , z , w ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 1 3 6 , 0 , 3 4 , 0 } ) ;
}
@ -236,16 +235,16 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new Bgra5551 ( x , y , z , w ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new Bgra5551 ( x , y , z , w ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 2 4 , 0 , 1 3 1 } ) ;
new Bgra5551 ( x , y , z , w ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new Bgra5551 ( x , y , z , w ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 2 4 , 0 , 1 3 1 , 0 } ) ;
new Bgra5551 ( x , y , z , w ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new Bgra5551 ( x , y , z , w ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 1 3 1 , 0 , 2 4 } ) ;
new Bgra5551 ( x , y , z , w ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new Bgra5551 ( x , y , z , w ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 1 3 1 , 0 , 2 4 , 0 } ) ;
}
@ -287,21 +286,21 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new Byte4 ( x , y , z , w ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new Byte4 ( x , y , z , w ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 1 2 8 , 0 , 0 } ) ;
new Byte4 ( x , y , z , w ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new Byte4 ( x , y , z , w ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 1 2 8 , 0 , 0 , 0 } ) ;
new Byte4 ( x , y , z , w ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new Byte4 ( x , y , z , w ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 0 , 0 , 1 2 8 } ) ;
new Byte4 ( x , y , z , w ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new Byte4 ( x , y , z , w ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 0 , 0 , 1 2 8 , 0 } ) ;
Byte4 r = new Byte4 ( ) ;
r . PackFromBytes ( 2 0 , 3 8 , 0 , 2 5 5 ) ;
r . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
r . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 2 0 , 3 8 , 0 , 2 5 5 } ) ;
}
@ -326,16 +325,16 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new HalfSingle ( x ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new HalfSingle ( x ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 1 2 8 , 0 , 0 } ) ;
new HalfSingle ( x ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new HalfSingle ( x ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 1 2 8 , 0 , 0 , 2 5 5 } ) ;
new HalfSingle ( x ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new HalfSingle ( x ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 0 , 0 , 1 2 8 } ) ;
new HalfSingle ( x ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new HalfSingle ( x ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 0 , 0 , 1 2 8 , 2 5 5 } ) ;
}
@ -363,16 +362,16 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new HalfVector2 ( x , y ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new HalfVector2 ( x , y ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 1 2 8 , 6 4 , 0 } ) ;
new HalfVector2 ( x , y ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new HalfVector2 ( x , y ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 1 2 8 , 6 4 , 0 , 2 5 5 } ) ;
new HalfVector2 ( x , y ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new HalfVector2 ( x , y ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 0 , 6 4 , 1 2 8 } ) ;
new HalfVector2 ( x , y ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new HalfVector2 ( x , y ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 0 , 6 4 , 1 2 8 , 2 5 5 } ) ;
}
@ -409,16 +408,16 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new HalfVector4 ( x , y , z , w ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new HalfVector4 ( x , y , z , w ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 6 4 , 1 2 8 , 1 9 1 } ) ;
new HalfVector4 ( x , y , z , w ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new HalfVector4 ( x , y , z , w ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 6 4 , 1 2 8 , 1 9 1 , 2 5 5 } ) ;
new HalfVector4 ( x , y , z , w ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new HalfVector4 ( x , y , z , w ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 1 9 1 , 1 2 8 , 6 4 } ) ;
new HalfVector4 ( x , y , z , w ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new HalfVector4 ( x , y , z , w ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 1 9 1 , 1 2 8 , 6 4 , 2 5 5 } ) ;
}
@ -454,16 +453,16 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new NormalizedByte2 ( x , y ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new NormalizedByte2 ( x , y ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 1 4 1 , 9 0 , 0 } ) ;
new NormalizedByte2 ( x , y ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new NormalizedByte2 ( x , y ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 1 4 1 , 9 0 , 0 , 2 5 5 } ) ;
new NormalizedByte2 ( x , y ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new NormalizedByte2 ( x , y ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 0 , 9 0 , 1 4 1 } ) ;
new NormalizedByte2 ( x , y ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new NormalizedByte2 ( x , y ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 0 , 9 0 , 1 4 1 , 2 5 5 } ) ;
}
@ -499,26 +498,26 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new NormalizedByte4 ( x , y , z , w ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new NormalizedByte4 ( x , y , z , w ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 1 4 1 , 9 0 , 1 9 2 } ) ;
new NormalizedByte4 ( x , y , z , w ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new NormalizedByte4 ( x , y , z , w ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 1 4 1 , 9 0 , 1 9 2 , 3 9 } ) ;
new NormalizedByte4 ( x , y , z , w ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new NormalizedByte4 ( x , y , z , w ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 1 9 2 , 9 0 , 1 4 1 } ) ;
new NormalizedByte4 ( x , y , z , w ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new NormalizedByte4 ( x , y , z , w ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 1 9 2 , 9 0 , 1 4 1 , 3 9 } ) ;
// http://community.monogame.net/t/normalizedbyte4-texture2d-gives-different-results-from-xna/8012/8
NormalizedByte4 r = new NormalizedByte4 ( ) ;
r . PackFromBytes ( 9 , 1 1 5 , 2 0 2 , 1 2 7 ) ;
r . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
r . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 9 , 1 1 5 , 2 0 2 , 1 2 7 } ) ;
r . PackedValue = 0xff4af389 ;
r . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
r . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 9 , 1 1 5 , 2 0 2 , 1 2 7 } ) ;
}
@ -553,22 +552,22 @@ namespace ImageSharp.Tests.Colors
NormalizedShort2 n = new NormalizedShort2 ( ) ;
n . PackFromBytes ( 1 4 1 , 9 0 , 0 , 0 ) ;
n . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
n . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 1 4 1 , 9 0 , 0 } ) ;
// TODO: I don't think this can ever pass since the bytes are already truncated.
// Assert.Equal(3650751693, n.PackedValue);
new NormalizedShort2 ( x , y ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new NormalizedShort2 ( x , y ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 1 4 1 , 9 0 , 0 } ) ;
new NormalizedShort2 ( x , y ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new NormalizedShort2 ( x , y ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 1 4 1 , 9 0 , 0 , 2 5 5 } ) ;
new NormalizedShort2 ( x , y ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new NormalizedShort2 ( x , y ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 0 , 9 0 , 1 4 1 } ) ;
new NormalizedShort2 ( x , y ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new NormalizedShort2 ( x , y ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 0 , 9 0 , 1 4 1 , 2 5 5 } ) ;
}
@ -600,21 +599,21 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new NormalizedShort4 ( x , y , z , w ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new NormalizedShort4 ( x , y , z , w ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 1 4 1 , 9 0 , 1 9 2 } ) ;
new NormalizedShort4 ( x , y , z , w ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new NormalizedShort4 ( x , y , z , w ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 1 4 1 , 9 0 , 1 9 2 , 3 9 } ) ;
new NormalizedShort4 ( x , y , z , w ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new NormalizedShort4 ( x , y , z , w ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 1 9 2 , 9 0 , 1 4 1 } ) ;
new NormalizedShort4 ( x , y , z , w ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new NormalizedShort4 ( x , y , z , w ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 1 9 2 , 9 0 , 1 4 1 , 3 9 } ) ;
NormalizedShort4 r = new NormalizedShort4 ( ) ;
r . PackFromBytes ( 9 , 1 1 5 , 2 0 2 , 1 2 7 ) ;
r . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
r . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 9 , 1 1 5 , 2 0 2 , 1 2 7 } ) ;
}
@ -647,16 +646,16 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new Rg32 ( x , y ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new Rg32 ( x , y ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 2 5 , 0 , 0 } ) ;
new Rg32 ( x , y ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new Rg32 ( x , y ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 2 5 , 0 , 0 , 2 5 5 } ) ;
new Rg32 ( x , y ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new Rg32 ( x , y ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 0 , 0 , 2 5 } ) ;
new Rg32 ( x , y ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new Rg32 ( x , y ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 0 , 0 , 2 5 , 2 5 5 } ) ;
}
@ -692,22 +691,22 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new Rgba1010102 ( x , y , z , w ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new Rgba1010102 ( x , y , z , w ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 2 5 , 0 , 1 2 8 } ) ;
new Rgba1010102 ( x , y , z , w ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new Rgba1010102 ( x , y , z , w ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 2 5 , 0 , 1 2 8 , 0 } ) ;
new Rgba1010102 ( x , y , z , w ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new Rgba1010102 ( x , y , z , w ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 1 2 8 , 0 , 2 5 } ) ;
new Rgba1010102 ( x , y , z , w ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new Rgba1010102 ( x , y , z , w ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 1 2 8 , 0 , 2 5 , 0 } ) ;
// Alpha component accuracy will be awful.
Rgba1010102 r = new Rgba1010102 ( ) ;
r . PackFromBytes ( 2 5 , 0 , 1 2 8 , 0 ) ;
r . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
r . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 2 5 , 0 , 1 2 8 , 0 } ) ;
}
@ -741,21 +740,21 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new Rgba64 ( x , y , z , w ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new Rgba64 ( x , y , z , w ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 2 0 , 3 8 , 7 6 } ) ;
new Rgba64 ( x , y , z , w ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new Rgba64 ( x , y , z , w ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 2 0 , 3 8 , 7 6 , 1 1 5 } ) ;
new Rgba64 ( x , y , z , w ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new Rgba64 ( x , y , z , w ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 7 6 , 3 8 , 2 0 } ) ;
new Rgba64 ( x , y , z , w ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new Rgba64 ( x , y , z , w ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 7 6 , 3 8 , 2 0 , 1 1 5 } ) ;
Rgba64 r = new Rgba64 ( ) ;
r . PackFromBytes ( 2 0 , 3 8 , 7 6 , 1 1 5 ) ;
r . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
r . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 2 0 , 3 8 , 7 6 , 1 1 5 } ) ;
}
@ -796,21 +795,21 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new Short2 ( x , y ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new Short2 ( x , y ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 1 2 8 , 1 2 7 , 0 } ) ;
new Short2 ( x , y ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new Short2 ( x , y ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 1 2 8 , 1 2 7 , 0 , 2 5 5 } ) ;
new Short2 ( x , y ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new Short2 ( x , y ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 0 , 1 2 7 , 1 2 8 } ) ;
new Short2 ( x , y ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new Short2 ( x , y ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 0 , 1 2 7 , 1 2 8 , 2 5 5 } ) ;
Short2 r = new Short2 ( ) ;
r . PackFromBytes ( 2 0 , 3 8 , 0 , 2 5 5 ) ;
r . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
r . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 2 0 , 3 8 , 0 , 2 5 5 } ) ;
}
@ -853,21 +852,21 @@ namespace ImageSharp.Tests.Colors
byte [ ] bgr = new byte [ 3 ] ;
byte [ ] bgra = new byte [ 4 ] ;
new Short4 ( x , y , z , w ) . ToBytes ( rgb , 0 , ComponentOrder . XYZ ) ;
new Short4 ( x , y , z , w ) . ToXyz Bytes ( rgb , 0 ) ;
Assert . Equal ( rgb , new byte [ ] { 1 7 2 , 1 7 7 , 2 4 3 } ) ;
new Short4 ( x , y , z , w ) . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
new Short4 ( x , y , z , w ) . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 1 7 2 , 1 7 7 , 2 4 3 , 1 2 8 } ) ;
new Short4 ( x , y , z , w ) . ToBytes ( bgr , 0 , ComponentOrder . ZYX ) ;
new Short4 ( x , y , z , w ) . ToZyx Bytes ( bgr , 0 ) ;
Assert . Equal ( bgr , new byte [ ] { 2 4 3 , 1 7 7 , 1 7 2 } ) ;
new Short4 ( x , y , z , w ) . ToBytes ( bgra , 0 , ComponentOrder . ZYXW ) ;
new Short4 ( x , y , z , w ) . ToZyxw Bytes ( bgra , 0 ) ;
Assert . Equal ( bgra , new byte [ ] { 2 4 3 , 1 7 7 , 1 7 2 , 1 2 8 } ) ;
Short4 r = new Short4 ( ) ;
r . PackFromBytes ( 2 0 , 3 8 , 0 , 2 5 5 ) ;
r . ToBytes ( rgba , 0 , ComponentOrder . XYZW ) ;
r . ToXyzw Bytes ( rgba , 0 ) ;
Assert . Equal ( rgba , new byte [ ] { 2 0 , 3 8 , 0 , 2 5 5 } ) ;
}