Browse Source

Add Bit64 and cleanup

pull/2363/head
James Jackson-South 3 years ago
parent
commit
747923d953
  1. 45
      src/ImageSharp/Formats/Tiff/Constants/TiffPhotometricInterpretation.cs
  2. 51
      src/ImageSharp/Formats/Tiff/TiffBitsPerPixel.cs
  3. 4
      src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs
  4. 2
      tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs

45
src/ImageSharp/Formats/Tiff/Constants/TiffPhotometricInterpretation.cs

@ -9,9 +9,8 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Constants;
public enum TiffPhotometricInterpretation : ushort
{
/// <summary>
/// Bilevel and grayscale: 0 is imaged as white. The maximum value is imaged as black.
///
/// Not supported by the TiffEncoder.
/// <para>Bilevel and grayscale: 0 is imaged as white. The maximum value is imaged as black.</para>
/// <para>Not supported by the TiffEncoder.</para>
/// </summary>
WhiteIsZero = 0,
@ -31,58 +30,50 @@ public enum TiffPhotometricInterpretation : ushort
PaletteColor = 3,
/// <summary>
/// A transparency mask.
///
/// Not supported by the TiffEncoder.
/// <para>A transparency mask.</para>
/// <para>Not supported by the TiffEncoder.</para>
/// </summary>
TransparencyMask = 4,
/// <summary>
/// Separated: usually CMYK (see Section 16 of the TIFF 6.0 specification).
///
/// Not supported by the TiffEncoder.
/// <para>Separated: usually CMYK (see Section 16 of the TIFF 6.0 specification).</para>
/// <para>Not supported by the TiffEncoder.</para>
/// </summary>
Separated = 5,
/// <summary>
/// YCbCr (see Section 21 of the TIFF 6.0 specification).
///
/// Not supported by the TiffEncoder.
/// <para>YCbCr (see Section 21 of the TIFF 6.0 specification).</para>
/// <para>Not supported by the TiffEncoder.</para>
/// </summary>
YCbCr = 6,
/// <summary>
/// 1976 CIE L*a*b* (see Section 23 of the TIFF 6.0 specification).
///
/// Not supported by the TiffEncoder.
/// <para>1976 CIE L*a*b* (see Section 23 of the TIFF 6.0 specification).</para>
/// <para>Not supported by the TiffEncoder.</para>
/// </summary>
CieLab = 8,
/// <summary>
/// ICC L*a*b* (see TIFF Specification, supplement 1).
///
/// Not supported by the TiffEncoder.
/// <para>ICC L*a*b* (see TIFF Specification, supplement 1).</para>
/// <para>Not supported by the TiffEncoder.</para>
/// </summary>
IccLab = 9,
/// <summary>
/// ITU L*a*b* (see RFC2301).
///
/// Not supported by the TiffEncoder.
/// <para>ITU L*a*b* (see RFC2301).</para>
/// <para>Not supported by the TiffEncoder.</para>
/// </summary>
ItuLab = 10,
/// <summary>
/// Color Filter Array (see the DNG specification).
///
/// Not supported by the TiffEncoder.
/// <para>Color Filter Array (see the DNG specification).</para>
/// <para>Not supported by the TiffEncoder.</para>
/// </summary>
ColorFilterArray = 32803,
/// <summary>
/// Linear Raw (see the DNG specification).
///
/// Not supported by the TiffEncoder.
/// <para>Linear Raw (see the DNG specification).</para>
/// <para>Not supported by the TiffEncoder.</para>
/// </summary>
LinearRaw = 34892
}

51
src/ImageSharp/Formats/Tiff/TiffBitsPerPixel.cs

@ -19,9 +19,8 @@ public enum TiffBitsPerPixel
Bit4 = 4,
/// <summary>
/// 6 bits per pixel. 2 bit for each color channel.
///
/// Note: The TiffEncoder does not yet support 2 bits per color channel and will default to 24 bits per pixel instead.
/// <para>6 bits per pixel. 2 bit for each color channel.</para>
/// <para>Note: The TiffEncoder does not yet support 2 bits per color channel and will default to 24 bits per pixel instead.</para>
/// </summary>
Bit6 = 6,
@ -31,30 +30,26 @@ public enum TiffBitsPerPixel
Bit8 = 8,
/// <summary>
/// 10 bits per pixel, for gray images.
///
/// Note: The TiffEncoder does not yet support 10 bits per pixel and will default to 24 bits per pixel instead.
/// <para>10 bits per pixel, for gray images.</para>
/// <para>Note: The TiffEncoder does not yet support 10 bits per pixel and will default to 24 bits per pixel instead.</para>
/// </summary>
Bit10 = 10,
/// <summary>
/// 12 bits per pixel. 4 bit for each color channel.
///
/// Note: The TiffEncoder does not yet support 4 bits per color channel and will default to 24 bits per pixel instead.
/// <para>12 bits per pixel. 4 bit for each color channel.</para>
/// <para>Note: The TiffEncoder does not yet support 4 bits per color channel and will default to 24 bits per pixel instead.</para>
/// </summary>
Bit12 = 12,
/// <summary>
/// 14 bits per pixel, for gray images.
///
/// Note: The TiffEncoder does not yet support 14 bits per pixel images and will default to 24 bits per pixel instead.
/// <para>14 bits per pixel, for gray images.</para>
/// <para>Note: The TiffEncoder does not yet support 14 bits per pixel images and will default to 24 bits per pixel instead.</para>
/// </summary>
Bit14 = 14,
/// <summary>
/// 16 bits per pixel, for gray images.
///
/// Note: The TiffEncoder does not yet support 16 bits per color channel and will default to 16 bits grayscale instead.
/// <para>16 bits per pixel, for gray images.</para>
/// <para>Note: The TiffEncoder does not yet support 16 bits per color channel and will default to 16 bits grayscale instead.</para>
/// </summary>
Bit16 = 16,
@ -64,9 +59,8 @@ public enum TiffBitsPerPixel
Bit24 = 24,
/// <summary>
/// 30 bits per pixel. 10 bit for each color channel.
///
/// Note: The TiffEncoder does not yet support 10 bits per color channel and will default to 24 bits per pixel instead.
/// <para>30 bits per pixel. 10 bit for each color channel.</para>
/// <para>Note: The TiffEncoder does not yet support 10 bits per color channel and will default to 24 bits per pixel instead.</para>
/// </summary>
Bit30 = 30,
@ -76,23 +70,26 @@ public enum TiffBitsPerPixel
Bit32 = 32,
/// <summary>
/// 36 bits per pixel. 12 bit for each color channel.
///
/// Note: The TiffEncoder does not yet support 12 bits per color channel and will default to 24 bits per pixel instead.
/// <para>36 bits per pixel. 12 bit for each color channel.</para>
/// <para>Note: The TiffEncoder does not yet support 12 bits per color channel and will default to 24 bits per pixel instead.</para>
/// </summary>
Bit36 = 36,
/// <summary>
/// 42 bits per pixel. 14 bit for each color channel.
///
/// Note: The TiffEncoder does not yet support 14 bits per color channel and will default to 24 bits per pixel instead.
/// <para>42 bits per pixel. 14 bit for each color channel.</para>
/// <para>Note: The TiffEncoder does not yet support 14 bits per color channel and will default to 24 bits per pixel instead.</para>
/// </summary>
Bit42 = 42,
/// <summary>
/// 48 bits per pixel. 16 bit for each color channel.
///
/// Note: The TiffEncoder does not yet support 16 bits per color channel and will default to 24 bits per pixel instead.
/// <para>48 bits per pixel. 16 bit for each color channel.</para>
/// <para>Note: The TiffEncoder does not yet support 16 bits per color channel and will default to 24 bits per pixel instead.</para>
/// </summary>
Bit48 = 48,
/// <summary>
/// <para>64 bits per pixel. 16 bit for each color channel.</para>
/// <para>Note: The TiffEncoder does not yet support 16 bits per color channel and will default to 32 bits per pixel instead.</para>
/// </summary>
Bit64 = 64,
}

4
src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs

@ -391,6 +391,10 @@ internal sealed class TiffEncoderCore : IImageEncoderInternals
// Encoding not yet supported bits per pixel will default to 24 bits.
this.SetEncoderOptions(TiffBitsPerPixel.Bit24, TiffPhotometricInterpretation.Rgb, compression, TiffPredictor.None);
break;
case TiffBitsPerPixel.Bit64:
// Encoding not yet supported bits per pixel will default to 32 bits.
this.SetEncoderOptions(TiffBitsPerPixel.Bit32, TiffPhotometricInterpretation.Rgb, compression, TiffPredictor.None);
break;
default:
this.SetEncoderOptions(bitsPerPixel, TiffPhotometricInterpretation.Rgb, compression, predictor);
break;

2
tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs

@ -111,7 +111,7 @@ public class TiffMetadataTests
[Theory]
[InlineData(Cmyk, 1, TiffBitsPerPixel.Bit32, TiffPhotometricInterpretation.Separated, TiffInkSet.Cmyk)]
[InlineData(Cmyk64BitDeflate, 1, 64, TiffPhotometricInterpretation.Separated, TiffInkSet.Cmyk)]
[InlineData(Cmyk64BitDeflate, 1, TiffBitsPerPixel.Bit64, TiffPhotometricInterpretation.Separated, TiffInkSet.Cmyk)]
[InlineData(YCbCrJpegCompressed, 1, TiffBitsPerPixel.Bit24, TiffPhotometricInterpretation.YCbCr, null)]
public void Identify_Frames(string imagePath, int framesCount, TiffBitsPerPixel bitsPerPixel, TiffPhotometricInterpretation photometric, TiffInkSet? inkSet)
{

Loading…
Cancel
Save