OFFIS DCMTK  Version 3.6.0
dirgbpxt.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: DicomRGBPixelTemplate (Header)
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2011-11-17 16:13:14 $
22  * CVS/RCS Revision: $Revision: 1.19 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef DIRGBPXT_H
31 #define DIRGBPXT_H
32 
33 #include "dcmtk/config/osconfig.h"
34 
35 #include "dcmtk/dcmimage/dicopxt.h"
36 #include "dcmtk/dcmimgle/diinpx.h" /* gcc 3.4 needs this */
37 
38 
39 /*---------------------*
40  * class declaration *
41  *---------------------*/
42 
45 template<class T1, class T2>
47  : public DiColorPixelTemplate<T2>
48 {
49 
50  public:
51 
61  const DiInputPixel *pixel,
62  EI_Status &status,
63  const unsigned long planeSize,
64  const int bits)
65  : DiColorPixelTemplate<T2>(docu, pixel, 3, status)
66  {
67  if ((pixel != NULL) && (this->Count > 0) && (status == EIS_Normal))
68  convert(OFstatic_cast(const T1 *, pixel->getData()) + pixel->getPixelStart(), planeSize, bits);
69  }
70 
74  {
75  }
76 
77 
78  private:
79 
86  void convert(const T1 *pixel,
87  const unsigned long planeSize,
88  const int bits)
89  {
90  if (this->Init(pixel))
91  {
92  // use the number of input pixels derived from the length of the 'PixelData'
93  // attribute), but not more than the size of the intermediate buffer
94  const unsigned long count = (this->InputCount < this->Count) ? this->InputCount : this->Count;
95  const T1 offset = OFstatic_cast(T1, DicomImageClass::maxval(bits - 1));
96  register const T1 *p = pixel;
97  if (this->PlanarConfiguration)
98  {
99 /*
100  register T2 *q;
101  // number of pixels to be skipped (only applicable if 'PixelData' contains more
102  // pixels than expected)
103  const unsigned long skip = (this->InputCount > this->Count) ? (this->InputCount - this->Count) : 0;
104  for (int j = 0; j < 3; ++j)
105  {
106  q = this->Data[j];
107  for (i = count; i != 0; --i)
108  *(q++) = removeSign(*(p++), offset);
109  // skip to beginning of next plane
110  p += skip;
111  }
112 */
113  register unsigned long l;
114  register unsigned long i = 0;
115  while (i < count)
116  {
117  /* store current pixel index */
118  const unsigned long iStart = i;
119  /* for all planes ... */
120  for (int j = 0; j < 3; ++j)
121  {
122  /* convert a single plane */
123  for (l = planeSize, i = iStart; (l != 0) && (i < count); --l, ++i)
124  this->Data[j][i] = removeSign(*(p++), offset);
125  }
126  }
127  }
128  else
129  {
130  register int j;
131  register unsigned long i;
132  for (i = 0; i < count; ++i) /* for all pixel ... */
133  for (j = 0; j < 3; ++j)
134  this->Data[j][i] = removeSign(*(p++), offset); /* ... copy planes */
135  }
136  }
137  }
138 };
139 
140 
141 #endif
142 
143 
144 /*
145  *
146  * CVS/RCS Log:
147  * $Log: dirgbpxt.h,v $
148  * Revision 1.19 2011-11-17 16:13:14 joergr
149  * Minor fixes to keep XCode 4.2 on Mac OS X Lion (clang compiler) quiet.
150  *
151  * Revision 1.18 2010-10-14 13:16:30 joergr
152  * Updated copyright header. Added reference to COPYRIGHT file.
153  *
154  * Revision 1.17 2005/12/08 16:01:59 meichel
155  * Changed include path schema for all DCMTK header files
156  *
157  * Revision 1.16 2004/04/21 10:00:31 meichel
158  * Minor modifications for compilation with gcc 3.4.0
159  *
160  * Revision 1.15 2003/12/23 12:24:23 joergr
161  * Adapted type casts to new-style typecast operators defined in ofcast.h.
162  * Removed leading underscore characters from preprocessor symbols (reserved
163  * symbols). Updated copyright header.
164  * Replaced post-increment/decrement operators by pre-increment/decrement
165  * operators where appropriate (e.g. 'i++' by '++i').
166  *
167  * Revision 1.14 2002/06/26 16:19:46 joergr
168  * Enhanced handling of corrupted pixel data and/or length.
169  * Corrected decoding of multi-frame, planar images.
170  *
171  * Revision 1.13 2001/11/09 16:47:02 joergr
172  * Removed 'inline' specifier from certain methods.
173  *
174  * Revision 1.12 2001/06/01 15:49:32 meichel
175  * Updated copyright header
176  *
177  * Revision 1.11 2000/04/27 13:15:14 joergr
178  * Dcmimage library code now consistently uses ofConsole for error output.
179  *
180  * Revision 1.10 2000/03/08 16:21:53 meichel
181  * Updated copyright header.
182  *
183  * Revision 1.9 1999/09/17 14:03:46 joergr
184  * Enhanced efficiency of some "for" loops.
185  *
186  * Revision 1.8 1999/04/28 12:52:02 joergr
187  * Corrected some typos, comments and formatting.
188  *
189  * Revision 1.7 1999/02/03 16:54:27 joergr
190  * Moved global functions maxval() and determineRepresentation() to class
191  * DicomImageClass (as static methods).
192  *
193  * Revision 1.6 1999/01/20 14:46:39 joergr
194  * Replaced invocation of getCount() by member variable Count where possible.
195  *
196  * Revision 1.5 1998/11/27 14:18:18 joergr
197  * Added copyright message.
198  *
199  * Revision 1.4 1998/05/11 14:53:29 joergr
200  * Added CVS/RCS header to each file.
201  *
202  *
203  */


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