Skip to content

Commit

Permalink
Add Bit64 and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
JimBobSquarePants committed Mar 1, 2023
1 parent 91c3d5e commit 747923d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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 changes: 24 additions & 27 deletions src/ImageSharp/Formats/Tiff/TiffBitsPerPixel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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,

Expand All @@ -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,

Expand All @@ -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 changes: 4 additions & 0 deletions src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ private void SanitizeAndSetEncoderOptions(
// 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;
Expand Down
2 changes: 1 addition & 1 deletion tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void Identify_DetectsCorrectByteOrder(string imagePath, ByteOrder expecte

[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)
{
Expand Down

0 comments on commit 747923d

Please sign in to comment.