33 #include "dcmtk/config/osconfig.h"
35 #include "dcmtk/dcmimage/dicoopx.h"
36 #include "dcmtk/dcmimage/dicopx.h"
37 #include "dcmtk/dcmimgle/dipxrept.h"
39 #include "dcmtk/ofstd/ofbmanip.h"
48 template<
class T1,
class T2>
69 const unsigned long count,
70 const unsigned long frame,
82 Data = OFstatic_cast(T2 *, buffer);
83 convert(OFstatic_cast(
const T1 **, OFconst_cast(
void *, pixel->
getData())), frame *
FrameSize, bits1, bits2, planar, inverse);
98 const unsigned long count,
99 const unsigned long frame,
100 const unsigned long ,
108 Data = OFstatic_cast(T2 *, buffer);
134 return sizeof(T2) * 3;
143 return OFstatic_cast(
const void *,
Data);
152 return OFstatic_cast(
void *,
Data);
167 result = OFstatic_cast(
void *,
Data);
171 result = OFstatic_cast(
void *,
Data + ((plane == 1) ? 1 : 2) *
FrameSize);
173 result = OFstatic_cast(
void *,
Data + ((plane == 1) ? 1 : 2));
189 register T2 *p =
Data;
190 register unsigned long i;
193 for (j = 3; j != 0; --j)
194 stream << OFstatic_cast(
unsigned long, *(p++)) <<
" ";
210 register T2 *p =
Data;
211 register unsigned long i;
214 for (j = 3; j != 0; --j)
215 fprintf(stream,
"%lu ", OFstatic_cast(
unsigned long, *(p++)));
240 const unsigned long start,
246 if ((pixel[0] != NULL) && (pixel[1] != NULL) && (pixel[2] != NULL))
252 DCMIMAGE_DEBUG(
"converting color pixel data to output format");
253 register T2 *q =
Data;
254 register unsigned long i;
258 register const T1 *p;
261 for (
int j = 0; j < 3; ++j)
263 p = pixel[j] + start;
267 for (i =
Count; i != 0; --i)
268 *(q++) = max2 - OFstatic_cast(T2, *(p++));
270 for (i =
Count; i != 0; --i)
271 *(q++) = OFstatic_cast(T2, *(p++));
280 else if (bits1 < bits2)
284 const T2 gradient2 = OFstatic_cast(T2, gradient1);
285 for (
int j = 0; j < 3; ++j)
287 p = pixel[j] + start;
288 if (gradient1 == OFstatic_cast(
double, gradient2))
293 for (i =
Count; i != 0; --i)
294 *(q++) = max2 - OFstatic_cast(T2, *(p++)) * gradient2;
296 for (i =
Count; i != 0; --i)
297 *(q++) = OFstatic_cast(T2, *(p++)) * gradient2;
303 for (i =
Count; i != 0; --i)
304 *(q++) = max2 - OFstatic_cast(T2, OFstatic_cast(
double, *(p++)) * gradient1);
306 for (i =
Count; i != 0; --i)
307 *(q++) = OFstatic_cast(T2, OFstatic_cast(
double, *(p++)) * gradient1);
319 const int shift = bits1 - bits2;
320 for (
int j = 0; j < 3; ++j)
322 p = pixel[j] + start;
326 for (i =
Count; i != 0; --i)
327 *(q++) = max2 - OFstatic_cast(T2, *(p++) >> shift);
329 for (i =
Count; i != 0; --i)
330 *(q++) = OFstatic_cast(T2, *(p++) >> shift);
348 for (i = start; i < start +
Count; ++i)
349 for (j = 0; j < 3; ++j)
350 *(q++) = max2 - OFstatic_cast(T2, pixel[j][i]);
352 for (i = start; i < start +
Count; ++i)
353 for (j = 0; j < 3; ++j)
354 *(q++) = OFstatic_cast(T2, pixel[j][i]);
357 else if (bits1 < bits2)
361 const T2 gradient2 = OFstatic_cast(T2, gradient1);
362 if (gradient1 == OFstatic_cast(
double, gradient2))
367 for (i = start; i < start +
Count; ++i)
368 for (j = 0; j < 3; ++j)
369 *(q++) = max2 - OFstatic_cast(T2, pixel[j][i]) * gradient2;
371 for (i = start; i < start +
Count; ++i)
372 for (j = 0; j < 3; ++j)
373 *(q++) = OFstatic_cast(T2, pixel[j][i]) * gradient2;
379 for (i = start; i < start +
Count; ++i)
380 for (j = 0; j < 3; ++j)
381 *(q++) = max2 - OFstatic_cast(T2, OFstatic_cast(
double, pixel[j][i]) * gradient1);
383 for (i = start; i < start +
Count; ++i)
384 for (j = 0; j < 3; ++j)
385 *(q++) = OFstatic_cast(T2, OFstatic_cast(
double, pixel[j][i]) * gradient1);
391 const int shift = bits1 - bits2;
395 for (i = start; i < start +
Count; ++i)
396 for (j = 0; j < 3; ++j)
397 *(q++) = max2 - OFstatic_cast(T2, pixel[j][i] >> shift);
399 for (i = start; i < start +
Count; ++i)
400 for (j = 0; j < 3; ++j)
401 *(q++) = OFstatic_cast(T2, pixel[j][i] >> shift);
int writePPM(FILE *stream) const
write pixel data of selected frame to PPM/ASCII file
DiColorOutputPixelTemplate(void *buffer, const DiColorPixel *pixel, const unsigned long count, const unsigned long frame, const int bits1, const int bits2, const int planar, const int inverse)
constructor
DiColorOutputPixelTemplate(void *buffer, const DiPixel *pixel, const unsigned long count, const unsigned long frame, const unsigned long, const int planar)
constructor
const void * getPlane(const int plane) const
get pointer to given plane of output pixel data
int DeleteData
flag indicating whether the output data buffer should be deleted in the destructor ...
Template class to create color output data.
int isPlanar
flag indicating whether pixel data is stored color-by-pixel or color-by-plane
const void * getData() const
get pointer to output pixel data
size_t getItemSize() const
get size of one pixel / item in the pixel array
unsigned long Count
number of pixels per frame (intermediate representation)
EP_Representation getRepresentation() const
get integer representation
virtual void * getDataPtr()
get pointer to output pixel data
virtual const void * getData() const =0
get pointer to pixel data (abstract).
const unsigned long FrameSize
number of pixels per frame (memory buffer size)
Template class to determine pixel representation.
Abstract base class to create color output data.
static void zeroMem(T *dest, const unsigned long count)
sets specified number of elements in destination memory to zero
Abstract base class to handle color pixel data.
static unsigned long maxval(const int mv_bits, const unsigned long mv_pos=1)
calculate maximum value which could be stored in the specified number of bits
T2 * Data
pointer to the storage area where the output data should be stored
int writePPM(STD_NAMESPACE ostream &stream) const
write pixel data of selected frame to PPM/ASCII file
virtual EP_Representation getRepresentation() const
determine integer representation for template type T
Abstract base class to handle pixel data.
void convert(const T1 *pixel[3], const unsigned long start, const int bits1, const int bits2, const int planar, const int inverse)
convert intermediate pixel data to output format (render pixel data)
virtual ~DiColorOutputPixelTemplate()
destructor