Scribus
Open source desktop publishing at your fingertips
sccolorspacedata_rgba.h
1 #ifndef SCCOLORSPACEDATA_RGBA_H
2 #define SCCOLORSPACEDATA_RGBA_H
3 
4 #include <cassert>
5 #include <climits>
6 #include <limits>
7 #include "sccolorprofile.h"
8 #include "sccolorspacedata.h"
9 
10 template<typename T, eColorFormat COLORFORMAT>
12 {
13 protected:
14  int m_rIndex;
15  int m_gIndex;
16  int m_bIndex;
17  int m_aIndex;
18 
19 public:
21 
22  virtual uint alphaIndex(void) const { return m_aIndex; }
23  virtual void flattenAlpha(void* dataIn, uint numElems) const;
24 };
25 
26 template<typename T, eColorFormat COLORFORMAT>
28 {
29  m_colorFormat = COLORFORMAT;
30  m_profile = profile;
31  if (m_colorFormat == Format_RGBA_8 || m_colorFormat == Format_RGBA_16)
32  {
33  m_rIndex = 0;
34  m_gIndex = 1;
35  m_bIndex = 2;
36  m_aIndex = 3;
37  }
38  else if (m_colorFormat == Format_ARGB_8 || m_colorFormat == Format_ARGB_16)
39  {
40  m_rIndex = 1;
41  m_gIndex = 2;
42  m_bIndex = 3;
43  m_aIndex = 0;
44  }
45  else if (m_colorFormat == Format_BGRA_8 || m_colorFormat == Format_BGRA_16)
46  {
47  m_rIndex = 2;
48  m_gIndex = 1;
49  m_bIndex = 0;
50  m_aIndex = 3;
51  }
52  else
53  {
54  assert(false);
55  }
56  if (m_profile)
57  {
58  assert(m_profile.colorSpace() == ColorSpace_Rgb);
59  }
60 };
61 
62 template<typename T, eColorFormat COLORFORMAT>
63 void ScColorSpaceDataTempl_RGBA<T, COLORFORMAT>::flattenAlpha(void* dataIn, uint numElems) const
64 {
65  T* data = ((T*) dataIn) + m_aIndex;
66  T nLimit = std::numeric_limits<T>::max();
67  while (numElems > 0)
68  {
69  *data = nLimit;
70  data += 4;
71  --numElems;
72  };
73 };
74 
81 
82 #endif
Definition: sccolorprofile.h:16
Definition: sccolorspacedata.h:17
Definition: sccolorspacedata_rgba.h:11