Skip to content

Commit 747923d

Browse files
Add Bit64 and cleanup
1 parent 91c3d5e commit 747923d

File tree

4 files changed

+47
-55
lines changed

4 files changed

+47
-55
lines changed

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

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Constants;
99
public enum TiffPhotometricInterpretation : ushort
1010
{
1111
/// <summary>
12-
/// Bilevel and grayscale: 0 is imaged as white. The maximum value is imaged as black.
13-
///
14-
/// Not supported by the TiffEncoder.
12+
/// <para>Bilevel and grayscale: 0 is imaged as white. The maximum value is imaged as black.</para>
13+
/// <para>Not supported by the TiffEncoder.</para>
1514
/// </summary>
1615
WhiteIsZero = 0,
1716

@@ -31,58 +30,50 @@ public enum TiffPhotometricInterpretation : ushort
3130
PaletteColor = 3,
3231

3332
/// <summary>
34-
/// A transparency mask.
35-
///
36-
/// Not supported by the TiffEncoder.
33+
/// <para>A transparency mask.</para>
34+
/// <para>Not supported by the TiffEncoder.</para>
3735
/// </summary>
3836
TransparencyMask = 4,
3937

4038
/// <summary>
41-
/// Separated: usually CMYK (see Section 16 of the TIFF 6.0 specification).
42-
///
43-
/// Not supported by the TiffEncoder.
39+
/// <para>Separated: usually CMYK (see Section 16 of the TIFF 6.0 specification).</para>
40+
/// <para>Not supported by the TiffEncoder.</para>
4441
/// </summary>
4542
Separated = 5,
4643

4744
/// <summary>
48-
/// YCbCr (see Section 21 of the TIFF 6.0 specification).
49-
///
50-
/// Not supported by the TiffEncoder.
45+
/// <para>YCbCr (see Section 21 of the TIFF 6.0 specification).</para>
46+
/// <para>Not supported by the TiffEncoder.</para>
5147
/// </summary>
5248
YCbCr = 6,
5349

5450
/// <summary>
55-
/// 1976 CIE L*a*b* (see Section 23 of the TIFF 6.0 specification).
56-
///
57-
/// Not supported by the TiffEncoder.
51+
/// <para>1976 CIE L*a*b* (see Section 23 of the TIFF 6.0 specification).</para>
52+
/// <para>Not supported by the TiffEncoder.</para>
5853
/// </summary>
5954
CieLab = 8,
6055

6156
/// <summary>
62-
/// ICC L*a*b* (see TIFF Specification, supplement 1).
63-
///
64-
/// Not supported by the TiffEncoder.
57+
/// <para>ICC L*a*b* (see TIFF Specification, supplement 1).</para>
58+
/// <para>Not supported by the TiffEncoder.</para>
6559
/// </summary>
6660
IccLab = 9,
6761

6862
/// <summary>
69-
/// ITU L*a*b* (see RFC2301).
70-
///
71-
/// Not supported by the TiffEncoder.
63+
/// <para>ITU L*a*b* (see RFC2301).</para>
64+
/// <para>Not supported by the TiffEncoder.</para>
7265
/// </summary>
7366
ItuLab = 10,
7467

7568
/// <summary>
76-
/// Color Filter Array (see the DNG specification).
77-
///
78-
/// Not supported by the TiffEncoder.
69+
/// <para>Color Filter Array (see the DNG specification).</para>
70+
/// <para>Not supported by the TiffEncoder.</para>
7971
/// </summary>
8072
ColorFilterArray = 32803,
8173

8274
/// <summary>
83-
/// Linear Raw (see the DNG specification).
84-
///
85-
/// Not supported by the TiffEncoder.
75+
/// <para>Linear Raw (see the DNG specification).</para>
76+
/// <para>Not supported by the TiffEncoder.</para>
8677
/// </summary>
8778
LinearRaw = 34892
8879
}

src/ImageSharp/Formats/Tiff/TiffBitsPerPixel.cs

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ public enum TiffBitsPerPixel
1919
Bit4 = 4,
2020

2121
/// <summary>
22-
/// 6 bits per pixel. 2 bit for each color channel.
23-
///
24-
/// Note: The TiffEncoder does not yet support 2 bits per color channel and will default to 24 bits per pixel instead.
22+
/// <para>6 bits per pixel. 2 bit for each color channel.</para>
23+
/// <para>Note: The TiffEncoder does not yet support 2 bits per color channel and will default to 24 bits per pixel instead.</para>
2524
/// </summary>
2625
Bit6 = 6,
2726

@@ -31,30 +30,26 @@ public enum TiffBitsPerPixel
3130
Bit8 = 8,
3231

3332
/// <summary>
34-
/// 10 bits per pixel, for gray images.
35-
///
36-
/// Note: The TiffEncoder does not yet support 10 bits per pixel and will default to 24 bits per pixel instead.
33+
/// <para>10 bits per pixel, for gray images.</para>
34+
/// <para>Note: The TiffEncoder does not yet support 10 bits per pixel and will default to 24 bits per pixel instead.</para>
3735
/// </summary>
3836
Bit10 = 10,
3937

4038
/// <summary>
41-
/// 12 bits per pixel. 4 bit for each color channel.
42-
///
43-
/// Note: The TiffEncoder does not yet support 4 bits per color channel and will default to 24 bits per pixel instead.
39+
/// <para>12 bits per pixel. 4 bit for each color channel.</para>
40+
/// <para>Note: The TiffEncoder does not yet support 4 bits per color channel and will default to 24 bits per pixel instead.</para>
4441
/// </summary>
4542
Bit12 = 12,
4643

4744
/// <summary>
48-
/// 14 bits per pixel, for gray images.
49-
///
50-
/// Note: The TiffEncoder does not yet support 14 bits per pixel images and will default to 24 bits per pixel instead.
45+
/// <para>14 bits per pixel, for gray images.</para>
46+
/// <para>Note: The TiffEncoder does not yet support 14 bits per pixel images and will default to 24 bits per pixel instead.</para>
5147
/// </summary>
5248
Bit14 = 14,
5349

5450
/// <summary>
55-
/// 16 bits per pixel, for gray images.
56-
///
57-
/// Note: The TiffEncoder does not yet support 16 bits per color channel and will default to 16 bits grayscale instead.
51+
/// <para>16 bits per pixel, for gray images.</para>
52+
/// <para>Note: The TiffEncoder does not yet support 16 bits per color channel and will default to 16 bits grayscale instead.</para>
5853
/// </summary>
5954
Bit16 = 16,
6055

@@ -64,9 +59,8 @@ public enum TiffBitsPerPixel
6459
Bit24 = 24,
6560

6661
/// <summary>
67-
/// 30 bits per pixel. 10 bit for each color channel.
68-
///
69-
/// Note: The TiffEncoder does not yet support 10 bits per color channel and will default to 24 bits per pixel instead.
62+
/// <para>30 bits per pixel. 10 bit for each color channel.</para>
63+
/// <para>Note: The TiffEncoder does not yet support 10 bits per color channel and will default to 24 bits per pixel instead.</para>
7064
/// </summary>
7165
Bit30 = 30,
7266

@@ -76,23 +70,26 @@ public enum TiffBitsPerPixel
7670
Bit32 = 32,
7771

7872
/// <summary>
79-
/// 36 bits per pixel. 12 bit for each color channel.
80-
///
81-
/// Note: The TiffEncoder does not yet support 12 bits per color channel and will default to 24 bits per pixel instead.
73+
/// <para>36 bits per pixel. 12 bit for each color channel.</para>
74+
/// <para>Note: The TiffEncoder does not yet support 12 bits per color channel and will default to 24 bits per pixel instead.</para>
8275
/// </summary>
8376
Bit36 = 36,
8477

8578
/// <summary>
86-
/// 42 bits per pixel. 14 bit for each color channel.
87-
///
88-
/// Note: The TiffEncoder does not yet support 14 bits per color channel and will default to 24 bits per pixel instead.
79+
/// <para>42 bits per pixel. 14 bit for each color channel.</para>
80+
/// <para>Note: The TiffEncoder does not yet support 14 bits per color channel and will default to 24 bits per pixel instead.</para>
8981
/// </summary>
9082
Bit42 = 42,
9183

9284
/// <summary>
93-
/// 48 bits per pixel. 16 bit for each color channel.
94-
///
95-
/// Note: The TiffEncoder does not yet support 16 bits per color channel and will default to 24 bits per pixel instead.
85+
/// <para>48 bits per pixel. 16 bit for each color channel.</para>
86+
/// <para>Note: The TiffEncoder does not yet support 16 bits per color channel and will default to 24 bits per pixel instead.</para>
9687
/// </summary>
9788
Bit48 = 48,
89+
90+
/// <summary>
91+
/// <para>64 bits per pixel. 16 bit for each color channel.</para>
92+
/// <para>Note: The TiffEncoder does not yet support 16 bits per color channel and will default to 32 bits per pixel instead.</para>
93+
/// </summary>
94+
Bit64 = 64,
9895
}

src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ private void SanitizeAndSetEncoderOptions(
391391
// Encoding not yet supported bits per pixel will default to 24 bits.
392392
this.SetEncoderOptions(TiffBitsPerPixel.Bit24, TiffPhotometricInterpretation.Rgb, compression, TiffPredictor.None);
393393
break;
394+
case TiffBitsPerPixel.Bit64:
395+
// Encoding not yet supported bits per pixel will default to 32 bits.
396+
this.SetEncoderOptions(TiffBitsPerPixel.Bit32, TiffPhotometricInterpretation.Rgb, compression, TiffPredictor.None);
397+
break;
394398
default:
395399
this.SetEncoderOptions(bitsPerPixel, TiffPhotometricInterpretation.Rgb, compression, predictor);
396400
break;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void Identify_DetectsCorrectByteOrder(string imagePath, ByteOrder expecte
111111

112112
[Theory]
113113
[InlineData(Cmyk, 1, TiffBitsPerPixel.Bit32, TiffPhotometricInterpretation.Separated, TiffInkSet.Cmyk)]
114-
[InlineData(Cmyk64BitDeflate, 1, 64, TiffPhotometricInterpretation.Separated, TiffInkSet.Cmyk)]
114+
[InlineData(Cmyk64BitDeflate, 1, TiffBitsPerPixel.Bit64, TiffPhotometricInterpretation.Separated, TiffInkSet.Cmyk)]
115115
[InlineData(YCbCrJpegCompressed, 1, TiffBitsPerPixel.Bit24, TiffPhotometricInterpretation.YCbCr, null)]
116116
public void Identify_Frames(string imagePath, int framesCount, TiffBitsPerPixel bitsPerPixel, TiffPhotometricInterpretation photometric, TiffInkSet? inkSet)
117117
{

0 commit comments

Comments
 (0)