static PixelBuffer LoadBufferRGB8 (Stream stream, int width, int height) { PixelBuffer pix = new UInt16Buffer (width, height); int length = width * 3; byte [] buffer = new byte [length]; for (int row = 0; row < height; row++) { stream.Read (buffer, 0, buffer.Length); pix.Fill8 (row, 0, buffer, 0, buffer.Length); } return pix; }
static PixelBuffer LoadBufferRGB16 (Stream stream, int width, int height) { PixelBuffer pix = new UInt16Buffer (width, height); int count = width * 3; byte [] buffer = new byte [count * 2]; for (int row = 0; row < height; row++) { int len = 0; while (len < buffer.Length) { int read = stream.Read (buffer, len, buffer.Length - len); if (read < 0) break; len += read; } pix.Fill16 (row, 0, buffer, 0, count, false); } return pix; }