public byte[] GetBytes() { var result = new byte[14]; BinaryThings.PutBytesIntoBytes(BinaryThings.FromStringToBytes(HeaderField), result, 0); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUintToBytes(Size), result, 2); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUintToBytes(Reserved), result, 6); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUintToBytes(PixelArrayAddress), result, 10); return(result); }
public byte[] GetBytes() { var result = new byte[SizeOfHeader]; BinaryThings.PutBytesIntoBytes(BinaryThings.FromUintToBytes(SizeOfHeader), result, 0); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUshortToBytes(Width), result, 4); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUshortToBytes(Height), result, 6); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUshortToBytes(Planes), result, 8); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUshortToBytes(BitsPerPixel), result, 10); return(result); }
public void PutPixel(uint x, uint y, byte a, byte r, byte g, byte b) { if (x >= DIBH.Width) { throw new IndexOutOfRangeException(String.Format("x should be between {0} and {1}. Received: {2}", 0, DIBH.Width - 1, x)); } if (y >= DIBH.Height) { throw new IndexOutOfRangeException(String.Format("y should be between {0} and {1}. Received: {2}", 0, DIBH.Height - 1, y)); } BinaryThings.PutBytesIntoBytes(new byte[] { a, r, g, b }, PixelMap, (y * DIBH.Width + x) * 4); }
public byte[] GetBytes() { var result = new byte[SizeOfHeader]; BinaryThings.PutBytesIntoBytes(BinaryThings.FromUintToBytes(SizeOfHeader), result, 0); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUintToBytes(Width), result, 4); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUintToBytes(Height), result, 8); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUshortToBytes(Planes), result, 12); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUshortToBytes(BitsPerPixel), result, 14); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUintToBytes(Compression), result, 16); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUintToBytes(ImageSize), result, 20); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUintToBytes(HorResolution), result, 24); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUintToBytes(VerResolution), result, 28); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUintToBytes(NumberOfPalleteColors), result, 32); BinaryThings.PutBytesIntoBytes(BinaryThings.FromUintToBytes(NumberOfImportantColors), result, 36); return(result); }
public void Test1() { var bmp = new ARGB32WinBitmap(2, 2); bmp.PutPixel(1, 1, ARGB32.Black); bmp.PutPixel(0, 0, ARGB32.Black); bmp.PutPixel(0, 1, ARGB32.White); bmp.PutPixel(1, 0, ARGB32.White); using (var stream = bmp.OutputStream()) { var imageSnapshot = new byte[] { 0x42, 0x4D, 42, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 12, 0, 0, 0, 2, 0, 2, 0, 1, 0, 32, 0, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0 }; var snapshotSize = imageSnapshot.Length; var buffer = new byte[snapshotSize]; var r = stream.Read(buffer, 0, snapshotSize); ; Xunit.Assert.Equal(snapshotSize, r); Xunit.Assert.Equal(BinaryThings.SubArray(imageSnapshot, 0, 5), BinaryThings.SubArray(buffer, 0, 5)); Xunit.Assert.Equal(BinaryThings.SubArray(imageSnapshot, 5, 5), BinaryThings.SubArray(buffer, 5, 5)); Xunit.Assert.Equal(BinaryThings.SubArray(imageSnapshot, 10, 5), BinaryThings.SubArray(buffer, 10, 5)); Xunit.Assert.Equal(BinaryThings.SubArray(imageSnapshot, 15, 5), BinaryThings.SubArray(buffer, 15, 5)); Xunit.Assert.Equal(BinaryThings.SubArray(imageSnapshot, 20, 5), BinaryThings.SubArray(buffer, 20, 5)); Xunit.Assert.Equal(BinaryThings.SubArray(imageSnapshot, 25, 5), BinaryThings.SubArray(buffer, 25, 5)); Xunit.Assert.Equal(BinaryThings.SubArray(imageSnapshot, 30, 5), BinaryThings.SubArray(buffer, 30, 5)); Xunit.Assert.Equal(BinaryThings.SubArray(imageSnapshot, 35, 5), BinaryThings.SubArray(buffer, 35, 5)); Xunit.Assert.Equal(BinaryThings.SubArray(imageSnapshot, 40, 2), BinaryThings.SubArray(buffer, 40, 2)); } }