public void ValidOneTimesOne16Bit() { var bodyRawBytes = new object[] { 'P', '6', '\n', '1', ' ', '1', ' ', '6', '5', '5', '3', '5', '\n', 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC }; var bodyBytes = bodyRawBytes.Select(Convert.ToByte).ToArray(); var factory = new ImageFactories.Image16Factory(); var reader = new NetpbmReader(); NetpbmImage16 image; using (var bodyStream = new MemoryStream(bodyBytes, false)) { image = (NetpbmImage16)reader.ReadImage(bodyStream, factory); image.LoadData(); Assert.Equal(-1, bodyStream.ReadByte()); } Assert.Equal(1, image.Header.Width); Assert.Equal(1, image.Header.Height); Assert.Equal(65535, image.Header.HighestComponentValue); Assert.Equal(3, image.Header.Components.Count); Assert.Equal(Component.Red, image.Header.Components[0]); Assert.Equal(Component.Green, image.Header.Components[1]); Assert.Equal(Component.Blue, image.Header.Components[2]); Assert.Equal(0x1234, image.GetNativePixel(0, 0)[0]); Assert.Equal(0x5678, image.GetNativePixel(0, 0)[1]); Assert.Equal(0x9ABC, image.GetNativePixel(0, 0)[2]); }
public void ValidOneTimesOne16Bit() { const string bodyString = "P3\n1 1 65535\n4660 22136 39612"; var bodyBytes = UsAsciiEncoding.GetBytes(bodyString); var factory = new ImageFactories.Image16Factory(); var reader = new NetpbmReader(); NetpbmImage16 image; using (var bodyStream = new MemoryStream(bodyBytes, false)) { image = (NetpbmImage16)reader.ReadImage(bodyStream, factory); image.LoadData(); Assert.Equal(-1, bodyStream.ReadByte()); } Assert.Equal(1, image.Header.Width); Assert.Equal(1, image.Header.Height); Assert.Equal(65535, image.Header.HighestComponentValue); Assert.Equal(3, image.Header.Components.Count); Assert.Equal(Component.Red, image.Header.Components[0]); Assert.Equal(Component.Green, image.Header.Components[1]); Assert.Equal(Component.Blue, image.Header.Components[2]); Assert.Equal(0x1234, image.GetNativePixel(0, 0)[0]); Assert.Equal(0x5678, image.GetNativePixel(0, 0)[1]); Assert.Equal(0x9ABC, image.GetNativePixel(0, 0)[2]); }