1 /*
2 *
3 * Copyright (C) 1996-2010, 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: DicomColorPixel (Source)
19 *
20 */
21
22
23 #include "dcmtk/config/osconfig.h"
24 #include "dcmtk/dcmdata/dctypes.h"
25 #include "dcmtk/dcmdata/dcdeftag.h"
26
27 #include "dcmtk/dcmimage/dicopx.h"
28 #include "dcmtk/dcmimage/diqttype.h"
29 #include "dcmtk/dcmimgle/dimopx.h"
30 #include "dcmtk/dcmimgle/diinpx.h"
31 #include "dcmtk/dcmimgle/didocu.h"
32
33
34 /*----------------*
35 * constructors *
36 *----------------*/
37
DiColorPixel(const DiDocument * docu,const DiInputPixel * pixel,const Uint16 samples,EI_Status & status,const Uint16 sample_rate)38 DiColorPixel::DiColorPixel(const DiDocument *docu,
39 const DiInputPixel *pixel,
40 const Uint16 samples,
41 EI_Status &status,
42 const Uint16 sample_rate)
43 : DiPixel(0),
44 PlanarConfiguration(0)
45 {
46 if (docu != NULL)
47 {
48 Uint16 us = 0;
49 if (docu->getValue(DCM_SamplesPerPixel, us))
50 {
51 if (us != samples)
52 {
53 DCMIMAGE_WARN("invalid value for 'SamplesPerPixel' (" << us
54 << ") ... assuming " << samples);
55 }
56 if (docu->getValue(DCM_PlanarConfiguration, us))
57 {
58 /* only use Planar Configuration attribute if there are multiple planes */
59 if (samples > 1)
60 {
61 PlanarConfiguration = (us == 1);
62 if ((us != 0) && (us != 1))
63 {
64 DCMIMAGE_WARN("invalid value for 'PlanarConfiguration' (" << us
65 << ") ... assuming 'color-by-pixel' (0)");
66 }
67 } else {
68 DCMIMAGE_WARN("unexpected attribute 'PlanarConfiguration' (" << us
69 << ") ... ignoring");
70 }
71 }
72 else if (samples > 1)
73 {
74 status = EIS_MissingAttribute;
75 DCMIMAGE_ERROR("mandatory attribute 'PlanarConfiguration' is missing");
76 return;
77 }
78 if (pixel != NULL)
79 {
80 // number of pixels (per plane) computed from the length of the PixelData attribute
81 InputCount = pixel->getPixelCount() / ((sample_rate == 0) ? samples : sample_rate);
82 // number of pixels allocated for the intermediate buffer
83 Count = pixel->getComputedCount() / ((sample_rate == 0) ? samples : sample_rate);
84 }
85 } else {
86 status = EIS_MissingAttribute;
87 DCMIMAGE_ERROR("mandatory attribute 'SamplesPerPixel' is missing");
88 }
89 }
90 }
91
DiColorPixel(const DiColorPixel * pixel,const unsigned long count)92 DiColorPixel::DiColorPixel(const DiColorPixel *pixel,
93 const unsigned long count)
94 : DiPixel(count, pixel->InputCount),
95 PlanarConfiguration(pixel->PlanarConfiguration)
96 {
97 }
98
99
100 /*--------------*
101 * destructor *
102 *--------------*/
103
~DiColorPixel()104 DiColorPixel::~DiColorPixel()
105 {
106 }
107