|
|
|
@ -2,6 +2,7 @@ |
|
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
|
|
|
using SixLabors.ImageSharp.Memory; |
|
|
|
using SixLabors.ImageSharp.PixelFormats; |
|
|
|
|
|
|
|
@ -25,19 +26,24 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Tiff |
|
|
|
int offset = 0; |
|
|
|
bool isOddWidth = (width & 1) == 1; |
|
|
|
|
|
|
|
var rgba = default(Rgba32); |
|
|
|
for (int y = top; y < top + height; y++) |
|
|
|
{ |
|
|
|
for (int x = left; x < left + width - 1; x += 2) |
|
|
|
for (int x = left; x < left + width - 1;) |
|
|
|
{ |
|
|
|
byte byteData = data[offset++]; |
|
|
|
|
|
|
|
byte intensity1 = (byte)((15 - ((byteData & 0xF0) >> 4)) * 17); |
|
|
|
color.FromRgba32(new Rgba32(intensity1, intensity1, intensity1, 255)); |
|
|
|
pixels[x, y] = color; |
|
|
|
rgba.PackedValue = (uint)(intensity1 | (intensity1 << 8) | (intensity1 << 16) | (0xff << 24)); |
|
|
|
color.FromRgba32(rgba); |
|
|
|
|
|
|
|
pixels[x++, y] = color; |
|
|
|
|
|
|
|
byte intensity2 = (byte)((15 - (byteData & 0x0F)) * 17); |
|
|
|
color.FromRgba32(new Rgba32(intensity2, intensity2, intensity2, 255)); |
|
|
|
pixels[x + 1, y] = color; |
|
|
|
rgba.PackedValue = (uint)(intensity2 | (intensity2 << 8) | (intensity2 << 16) | (0xff << 24)); |
|
|
|
color.FromRgba32(rgba); |
|
|
|
|
|
|
|
pixels[x++, y] = color; |
|
|
|
} |
|
|
|
|
|
|
|
if (isOddWidth) |
|
|
|
@ -45,7 +51,9 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Tiff |
|
|
|
byte byteData = data[offset++]; |
|
|
|
|
|
|
|
byte intensity1 = (byte)((15 - ((byteData & 0xF0) >> 4)) * 17); |
|
|
|
color.FromRgba32(new Rgba32(intensity1, intensity1, intensity1, 255)); |
|
|
|
rgba.PackedValue = (uint)(intensity1 | (intensity1 << 8) | (intensity1 << 16) | (0xff << 24)); |
|
|
|
color.FromRgba32(rgba); |
|
|
|
|
|
|
|
pixels[left + width - 1, y] = color; |
|
|
|
} |
|
|
|
} |
|
|
|
|