|
|
|
@ -371,35 +371,36 @@ namespace SixLabors.ImageSharp.Formats.Bmp |
|
|
|
padding = 4 - padding; |
|
|
|
} |
|
|
|
|
|
|
|
byte[] row = new byte[arrayWidth + padding]; |
|
|
|
var color = default(TPixel); |
|
|
|
|
|
|
|
var rgba = default(Rgba32); |
|
|
|
|
|
|
|
for (int y = 0; y < height; y++) |
|
|
|
using (var row = Buffer<byte>.CreateClean(arrayWidth + padding)) |
|
|
|
{ |
|
|
|
int newY = Invert(y, height, inverted); |
|
|
|
this.currentStream.Read(row, 0, row.Length); |
|
|
|
int offset = 0; |
|
|
|
Span<TPixel> pixelRow = pixels.GetRowSpan(newY); |
|
|
|
var color = default(TPixel); |
|
|
|
var rgba = new Rgba32(0, 0, 0, 255); |
|
|
|
|
|
|
|
// TODO: Could use PixelOperations here!
|
|
|
|
for (int x = 0; x < arrayWidth; x++) |
|
|
|
for (int y = 0; y < height; y++) |
|
|
|
{ |
|
|
|
int colOffset = x * ppb; |
|
|
|
int newY = Invert(y, height, inverted); |
|
|
|
this.currentStream.Read(row.Array, 0, row.Length); |
|
|
|
int offset = 0; |
|
|
|
Span<TPixel> pixelRow = pixels.GetRowSpan(newY); |
|
|
|
|
|
|
|
for (int shift = 0; shift < ppb && (x + shift) < width; shift++) |
|
|
|
// TODO: Could use PixelOperations here!
|
|
|
|
for (int x = 0; x < arrayWidth; x++) |
|
|
|
{ |
|
|
|
int colorIndex = ((row[offset] >> (8 - bits - (shift * bits))) & mask) * 4; |
|
|
|
int newX = colOffset + shift; |
|
|
|
int colOffset = x * ppb; |
|
|
|
|
|
|
|
// Stored in b-> g-> r order.
|
|
|
|
rgba.Bgr = Unsafe.As<byte, Bgr24>(ref colors[colorIndex]); |
|
|
|
color.PackFromRgba32(rgba); |
|
|
|
pixelRow[newX] = color; |
|
|
|
} |
|
|
|
for (int shift = 0; shift < ppb && (x + shift) < width; shift++) |
|
|
|
{ |
|
|
|
int colorIndex = ((row[offset] >> (8 - bits - (shift * bits))) & mask) * 4; |
|
|
|
int newX = colOffset + shift; |
|
|
|
|
|
|
|
offset++; |
|
|
|
// Stored in b-> g-> r order.
|
|
|
|
rgba.Bgr = Unsafe.As<byte, Bgr24>(ref colors[colorIndex]); |
|
|
|
color.PackFromRgba32(rgba); |
|
|
|
pixelRow[newX] = color; |
|
|
|
} |
|
|
|
|
|
|
|
offset++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|