Browse Source

Use new pixel packing methods

pull/1570/head
Andrew Wilkinson 9 years ago
parent
commit
f41eb1101c
  1. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor.cs
  2. 6
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor.cs
  3. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero8TiffColor.cs
  4. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb888TiffColor.cs
  5. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor.cs
  6. 6
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor.cs
  7. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor.cs

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor.cs

@ -44,7 +44,7 @@ namespace ImageSharp.Formats.Tiff
{
int bit = (b >> (7 - shift)) & 1;
byte intensity = (bit == 1) ? (byte)255 : (byte)0;
color.PackFromBytes(intensity, intensity, intensity, 255);
color.PackFromRgba32(new Rgba32(intensity, intensity, intensity, 255));
pixels[x + shift, y] = color;
}
}

6
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor.cs

@ -40,11 +40,11 @@ namespace ImageSharp.Formats.Tiff
byte byteData = data[offset++];
byte intensity1 = (byte)(((byteData & 0xF0) >> 4) * 17);
color.PackFromBytes(intensity1, intensity1, intensity1, 255);
color.PackFromRgba32(new Rgba32(intensity1, intensity1, intensity1, 255));
pixels[x, y] = color;
byte intensity2 = (byte)((byteData & 0x0F) * 17);
color.PackFromBytes(intensity2, intensity2, intensity2, 255);
color.PackFromRgba32(new Rgba32(intensity2, intensity2, intensity2, 255));
pixels[x + 1, y] = color;
}
@ -53,7 +53,7 @@ namespace ImageSharp.Formats.Tiff
byte byteData = data[offset++];
byte intensity1 = (byte)(((byteData & 0xF0) >> 4) * 17);
color.PackFromBytes(intensity1, intensity1, intensity1, 255);
color.PackFromRgba32(new Rgba32(intensity1, intensity1, intensity1, 255));
pixels[left + width - 1, y] = color;
}
}

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero8TiffColor.cs

@ -37,7 +37,7 @@ namespace ImageSharp.Formats.Tiff
for (int x = left; x < left + width; x++)
{
byte intensity = data[offset++];
color.PackFromBytes(intensity, intensity, intensity, 255);
color.PackFromRgba32(new Rgba32(intensity, intensity, intensity, 255));
pixels[x, y] = color;
}
}

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb888TiffColor.cs

@ -41,7 +41,7 @@ namespace ImageSharp.Formats.Tiff
byte r = data[offset++];
byte g = data[offset++];
byte b = data[offset++];
color.PackFromBytes(r, g, b, 255);
color.PackFromRgba32(new Rgba32(r, g, b, 255));
pixels[x, y] = color;
}
}

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor.cs

@ -44,7 +44,7 @@ namespace ImageSharp.Formats.Tiff
{
int bit = (b >> (7 - shift)) & 1;
byte intensity = (bit == 1) ? (byte)0 : (byte)255;
color.PackFromBytes(intensity, intensity, intensity, 255);
color.PackFromRgba32(new Rgba32(intensity, intensity, intensity, 255));
pixels[x + shift, y] = color;
}
}

6
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor.cs

@ -40,11 +40,11 @@ namespace ImageSharp.Formats.Tiff
byte byteData = data[offset++];
byte intensity1 = (byte)((15 - ((byteData & 0xF0) >> 4)) * 17);
color.PackFromBytes(intensity1, intensity1, intensity1, 255);
color.PackFromRgba32(new Rgba32(intensity1, intensity1, intensity1, 255));
pixels[x, y] = color;
byte intensity2 = (byte)((15 - (byteData & 0x0F)) * 17);
color.PackFromBytes(intensity2, intensity2, intensity2, 255);
color.PackFromRgba32(new Rgba32(intensity2, intensity2, intensity2, 255));
pixels[x + 1, y] = color;
}
@ -53,7 +53,7 @@ namespace ImageSharp.Formats.Tiff
byte byteData = data[offset++];
byte intensity1 = (byte)((15 - ((byteData & 0xF0) >> 4)) * 17);
color.PackFromBytes(intensity1, intensity1, intensity1, 255);
color.PackFromRgba32(new Rgba32(intensity1, intensity1, intensity1, 255));
pixels[left + width - 1, y] = color;
}
}

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor.cs

@ -37,7 +37,7 @@ namespace ImageSharp.Formats.Tiff
for (int x = left; x < left + width; x++)
{
byte intensity = (byte)(255 - data[offset++]);
color.PackFromBytes(intensity, intensity, intensity, 255);
color.PackFromRgba32(new Rgba32(intensity, intensity, intensity, 255));
pixels[x, y] = color;
}
}

Loading…
Cancel
Save