1 /*=========================================================================
2 
3   Program: GDCM (Grassroots DICOM). A DICOM library
4 
5   Copyright (c) 2006-2011 Mathieu Malaterre
6   All rights reserved.
7   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8 
9      This software is distributed WITHOUT ANY WARRANTY; without even
10      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11      PURPOSE.  See the above copyright notice for more information.
12 
13 =========================================================================*/
14 
15 #ifndef GDCMPHOTOMETRICINTERPRETATION_H
16 #define GDCMPHOTOMETRICINTERPRETATION_H
17 
18 #include "gdcmTypes.h"
19 #include <iostream>
20 
21 namespace gdcm
22 {
23 
24 class TransferSyntax;
25 /**
26  * \brief Class to represent an PhotometricInterpretation
27  */
28 class GDCM_EXPORT PhotometricInterpretation
29 {
30 public:
31   typedef enum {
32     UNKNOWN = 0,
33     MONOCHROME1,
34     MONOCHROME2,
35     PALETTE_COLOR,
36     RGB,
37     HSV,
38     ARGB, // retired
39     CMYK,
40     YBR_FULL,
41     YBR_FULL_422,
42     YBR_PARTIAL_422,
43     YBR_PARTIAL_420,
44     YBR_ICT,
45     YBR_RCT,
46     // PALETTE_COLOR ?
47     //MONOCHROME = MONOCHROME1 | MONOCHROME2,
48     //COLOR      = RGB | HSV | ARGB | CMYK | YBR_FULL | YBR_FULL_422 | YBR_PARTIAL_422 | YBR_PARTIAL_420 | YBR_ICT | YBR_RCT,
49     PI_END  // Helpful for internal implementation
50   } PIType; // PhotometricInterpretationType
51 
PIField(pi)52   PhotometricInterpretation(PIType pi = UNKNOWN):PIField(pi) {}
53 
54   static const char *GetPIString(PIType pi);
55 
56   const char *GetString() const;
57 
58   // You need to make sure end of string is \0
59   static PIType GetPIType(const char *pi);
60 
61   static bool IsRetired(PIType pi);
62 
63   bool IsLossy() const;
64   bool IsLossless() const;
65 
66   /// return the value for Sample Per Pixel associated with a particular Photometric Interpretation
67   unsigned short GetSamplesPerPixel() const;
68 
69   // TODO
70   // not all PhotometricInterpretation are allowed for compressed Transfer
71   // syntax
72   // static bool IsAllowedForCompressedTS(PIType pi);
73 
74   friend std::ostream& operator<<(std::ostream& os, const PhotometricInterpretation& pi);
75 
PIType()76   operator PIType () const { return PIField; }
77 
GetType()78   PIType GetType () const { return PIField; }
79 
80   // Will return whether current PhotometricInterpretation is the same Color Space as input:
81   // eg. RGB and YBR_RCT are
82   bool IsSameColorSpace( PhotometricInterpretation const &pi ) const;
83 
84   //static PIType GetEquivalent(TransferSyntax const &ts);
85 
86 private:
87   PIType PIField;
88 };
89 //-----------------------------------------------------------------------------
90 inline std::ostream& operator<<(std::ostream& os, const PhotometricInterpretation &val)
91 {
92   const char *s = PhotometricInterpretation::GetPIString(val.PIField);
93   os << (s ? s : "");
94   return os;
95 }
96 
97 
98 } // end namespace gdcm
99 
100 #endif //GDCMPHOTOMETRICINTERPRETATION_H
101