OFFIS DCMTK  Version 3.6.0
dipalpxt.h
1 /*
2  *
3  * Copyright (C) 1996-2011, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmimage
15  *
16  * Author: Joerg Riesmeier
17  *
18  * Purpose: DicomPalettePixelTemplate (Header)
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2011-11-17 16:13:14 $
22  * CVS/RCS Revision: $Revision: 1.25 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef DIPALPXT_H
31 #define DIPALPXT_H
32 
33 #include "dcmtk/config/osconfig.h"
34 
35 #include "dcmtk/dcmimage/dicopxt.h"
36 #include "dcmtk/dcmimgle/diluptab.h"
37 #include "dcmtk/dcmimgle/diinpx.h" /* gcc 3.4 needs this */
38 
39 
40 /*---------------------*
41  * class declaration *
42  *---------------------*/
43 
46 template<class T1, class T2, class T3>
48  : public DiColorPixelTemplate<T3>
49 {
50 
51  public:
52 
61  const DiInputPixel *pixel,
62  DiLookupTable *palette[3],
63  EI_Status &status)
64  : DiColorPixelTemplate<T3>(docu, pixel, 1, status)
65  {
66  if ((pixel != NULL) && (this->Count > 0) && (status == EIS_Normal))
67  {
68  if (this->PlanarConfiguration)
69  {
70  status = EIS_InvalidValue;
71  DCMIMAGE_ERROR("invalid value for 'PlanarConfiguration' (" << this->PlanarConfiguration << ")");
72  }
73  else
74  convert(OFstatic_cast(const T1 *, pixel->getData()) + pixel->getPixelStart(), palette);
75  }
76  }
77 
81  {
82  }
83 
84 
85  private:
86 
92  void convert(const T1 *pixel,
93  DiLookupTable *palette[3])
94  { // can be optimized if necessary !
95  if (this->Init(pixel))
96  {
97  register const T1 *p = pixel;
98  register T2 value = 0;
99  register unsigned long i;
100  register int j;
101  // use the number of input pixels derived from the length of the 'PixelData'
102  // attribute), but not more than the size of the intermediate buffer
103  const unsigned long count = (this->InputCount < this->Count) ? this->InputCount : this->Count;
104  for (i = 0; i < count; ++i)
105  {
106  value = OFstatic_cast(T2, *(p++));
107  for (j = 0; j < 3; ++j)
108  {
109  if (value <= palette[j]->getFirstEntry(value))
110  this->Data[j][i] = OFstatic_cast(T3, palette[j]->getFirstValue());
111  else if (value >= palette[j]->getLastEntry(value))
112  this->Data[j][i] = OFstatic_cast(T3, palette[j]->getLastValue());
113  else
114  this->Data[j][i] = OFstatic_cast(T3, palette[j]->getValue(value));
115  }
116  }
117  }
118  }
119 };
120 
121 
122 #endif
123 
124 
125 /*
126  *
127  * CVS/RCS Log:
128  * $Log: dipalpxt.h,v $
129  * Revision 1.25 2011-11-17 16:13:14 joergr
130  * Minor fixes to keep XCode 4.2 on Mac OS X Lion (clang compiler) quiet.
131  *
132  * Revision 1.24 2010-10-14 13:16:29 joergr
133  * Updated copyright header. Added reference to COPYRIGHT file.
134  *
135  * Revision 1.23 2010-03-01 09:08:46 uli
136  * Removed some unnecessary include directives in the headers.
137  *
138  * Revision 1.22 2009-11-25 14:31:21 joergr
139  * Removed inclusion of header file "ofconsol.h".
140  *
141  * Revision 1.21 2009-10-14 10:25:14 joergr
142  * Fixed minor issues in log output. Also updated copyright date (if required).
143  *
144  * Revision 1.20 2009-10-13 14:08:33 uli
145  * Switched to logging mechanism provided by the "new" oflog module
146  *
147  * Revision 1.19 2006-08-15 16:35:01 meichel
148  * Updated the code in module dcmimage to correctly compile when
149  * all standard C++ classes remain in namespace std.
150  *
151  * Revision 1.18 2005/12/08 16:01:41 meichel
152  * Changed include path schema for all DCMTK header files
153  *
154  * Revision 1.17 2004/04/21 10:00:31 meichel
155  * Minor modifications for compilation with gcc 3.4.0
156  *
157  * Revision 1.16 2003/12/23 11:50:30 joergr
158  * Adapted type casts to new-style typecast operators defined in ofcast.h.
159  * Removed leading underscore characters from preprocessor symbols (reserved
160  * symbols). Updated copyright header.
161  * Replaced post-increment/decrement operators by pre-increment/decrement
162  * operators where appropriate (e.g. 'i++' by '++i').
163  *
164  * Revision 1.15 2002/06/26 16:19:13 joergr
165  * Enhanced handling of corrupted pixel data and/or length.
166  * Corrected decoding of multi-frame, planar images.
167  *
168  * Revision 1.14 2001/11/09 16:47:02 joergr
169  * Removed 'inline' specifier from certain methods.
170  *
171  * Revision 1.13 2001/06/01 15:49:31 meichel
172  * Updated copyright header
173  *
174  * Revision 1.12 2000/04/27 13:15:14 joergr
175  * Dcmimage library code now consistently uses ofConsole for error output.
176  *
177  * Revision 1.11 2000/03/08 16:21:53 meichel
178  * Updated copyright header.
179  *
180  * Revision 1.10 1999/09/17 14:03:45 joergr
181  * Enhanced efficiency of some "for" loops.
182  *
183  * Revision 1.9 1999/05/03 11:03:06 joergr
184  * Minor code purifications to keep Sun CC 2.0.1 quiet.
185  *
186  * Revision 1.8 1999/04/28 12:52:01 joergr
187  * Corrected some typos, comments and formatting.
188  *
189  * Revision 1.7 1999/01/20 14:46:30 joergr
190  * Replaced invocation of getCount() by member variable Count where possible.
191  *
192  * Revision 1.6 1998/12/14 17:08:56 joergr
193  * Added support for signed values as second entry in look-up tables
194  * (= first value mapped).
195  *
196  * Revision 1.5 1998/11/27 14:17:31 joergr
197  * Added copyright message.
198  *
199  * Revision 1.4 1998/07/01 08:39:27 joergr
200  * Minor changes to avoid compiler warnings (gcc 2.8.1 with additional
201  * options), e.g. add copy constructors.
202  *
203  * Revision 1.3 1998/05/11 14:53:27 joergr
204  * Added CVS/RCS header to each file.
205  *
206  *
207  */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2