/// <summary> /// Get Image into Raw Bayern pattern (BGGR) /// </summary> public byte[] GetImage(int width = 640, int height = 480) { _io.WriteByte(CMD_RD_IMG); byte[] img = new byte[width * height]; // Read row by row for (int y = 0; y < height; y++) { while (_io.GetBytesAvailable() < width) { Thread.Sleep(2); } byte[] row = _io.Read(width); // Combine rows for (int x = 0; x < width; x++) { img[y * width + x] = row[x]; } } _io.ReadByte(); return(img); }
public static byte ReadByte(this StdIO stdio) { return(stdio.Read(1)[0]); }
public static UInt16 ReadUInt16(this StdIO stdio) { return(BitConverter.ToUInt16(stdio.Read(2), 0)); }