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:  dcmimgle
15  *
16  *  Author:  Joerg Riesmeier
17  *
18  *  Purpose: DicomMonoOutputPixel (Source)
19  *
20  *  Last Update:      $Author: joergr $
21  *  Update Date:      $Date: 2010-10-14 13:14:18 $
22  *  CVS/RCS Revision: $Revision: 1.9 $
23  *  Status:           $State: Exp $
24  *
25  *  CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #include "dcmtk/config/osconfig.h"
31 
32 #include "dcmtk/dcmimgle/dimoopx.h"
33 #include "dcmtk/dcmimgle/dimopx.h"
34 
35 
36 /*----------------*
37  *  constructors  *
38  *----------------*/
39 
DiMonoOutputPixel(const DiMonoPixel * pixel,const unsigned long size,const unsigned long frame,const unsigned long max)40 DiMonoOutputPixel::DiMonoOutputPixel(const DiMonoPixel *pixel,
41                                      const unsigned long size,
42                                      const unsigned long frame,
43                                      const unsigned long max)
44   : Count(0),
45     FrameSize(size),
46     UsedValues(NULL),
47     MaxValue(max)
48 {
49     if (pixel != NULL)
50     {
51         if (pixel->getCount() > frame * size)
52             Count = pixel->getCount() - frame * size;       // number of pixels remaining for this 'frame'
53     }
54     if (Count > FrameSize)
55         Count = FrameSize;                                  // cut off at frame 'size'
56 }
57 
58 
59 /*--------------*
60  *  destructor  *
61  *--------------*/
62 
~DiMonoOutputPixel()63 DiMonoOutputPixel::~DiMonoOutputPixel()
64 {
65     delete[] UsedValues;
66 }
67 
68 
69 /**********************************/
70 
71 
isUnused(const unsigned long value)72 int DiMonoOutputPixel::isUnused(const unsigned long value)
73 {
74     if (UsedValues == NULL)
75         determineUsedValues();                  // create on demand
76     if (UsedValues != NULL)
77     {
78         if (value <= MaxValue)
79             return OFstatic_cast(int, UsedValues[value] == 0);
80         return 2;                               // out of range
81     }
82     return 0;
83 }
84 
85 
86 /*
87  *
88  * CVS/RCS Log:
89  * $Log: dimoopx.cc,v $
90  * Revision 1.9  2010-10-14 13:14:18  joergr
91  * Updated copyright header. Added reference to COPYRIGHT file.
92  *
93  * Revision 1.8  2005/12/08 15:43:01  meichel
94  * Changed include path schema for all DCMTK header files
95  *
96  * Revision 1.7  2003/12/08 14:55:04  joergr
97  * Adapted type casts to new-style typecast operators defined in ofcast.h.
98  *
99  * Revision 1.6  2001/06/01 15:49:58  meichel
100  * Updated copyright header
101  *
102  * Revision 1.5  2000/03/08 16:24:31  meichel
103  * Updated copyright header.
104  *
105  * Revision 1.4  1999/07/23 13:45:39  joergr
106  * Enhanced handling of corrupted pixel data (wrong length).
107  *
108  * Revision 1.3  1999/02/11 16:53:35  joergr
109  * Added routine to check whether particular grayscale values are unused in
110  * the output data.
111  * Removed unused parameter / member variable.
112  *
113  * Revision 1.2  1999/01/20 14:54:30  joergr
114  * Replaced invocation of getCount() by member variable Count where possible.
115  *
116  * Revision 1.1  1998/11/27 16:15:02  joergr
117  * Added copyright message.
118  *
119  * Revision 1.3  1998/05/11 14:52:33  joergr
120  * Added CVS/RCS header to each file.
121  *
122  *
123  */
124