00001 /* 00002 * 00003 * Copyright (C) 1996-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmimage 00015 * 00016 * Author: Joerg Riesmeier 00017 * 00018 * Purpose: DicomPalettePixelTemplate (Header) 00019 * 00020 * Last Update: $Author: joergr $ 00021 * Update Date: $Date: 2010-10-14 13:16:29 $ 00022 * CVS/RCS Revision: $Revision: 1.24 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 00030 #ifndef DIPALPXT_H 00031 #define DIPALPXT_H 00032 00033 #include "dcmtk/config/osconfig.h" 00034 00035 #include "dcmtk/dcmimage/dicopxt.h" 00036 #include "dcmtk/dcmimgle/diluptab.h" 00037 #include "dcmtk/dcmimgle/diinpx.h" /* gcc 3.4 needs this */ 00038 00039 00040 /*---------------------* 00041 * class declaration * 00042 *---------------------*/ 00043 00046 template<class T1, class T2, class T3> 00047 class DiPalettePixelTemplate 00048 : public DiColorPixelTemplate<T3> 00049 { 00050 00051 public: 00052 00060 DiPalettePixelTemplate(const DiDocument *docu, 00061 const DiInputPixel *pixel, 00062 DiLookupTable *palette[3], 00063 EI_Status &status) 00064 : DiColorPixelTemplate<T3>(docu, pixel, 1, status) 00065 { 00066 if ((pixel != NULL) && (this->Count > 0) && (status == EIS_Normal)) 00067 { 00068 if (this->PlanarConfiguration) 00069 { 00070 status = EIS_InvalidValue; 00071 DCMIMAGE_ERROR("invalid value for 'PlanarConfiguration' (" << this->PlanarConfiguration << ")"); 00072 } 00073 else 00074 convert(OFstatic_cast(const T1 *, pixel->getData()) + pixel->getPixelStart(), palette); 00075 } 00076 } 00077 00080 virtual ~DiPalettePixelTemplate() 00081 { 00082 } 00083 00084 00085 private: 00086 00092 void convert(const T1 *pixel, 00093 DiLookupTable *palette[3]) 00094 { // can be optimized if necessary ! 00095 if (Init(pixel)) 00096 { 00097 register const T1 *p = pixel; 00098 register T2 value = 0; 00099 register unsigned long i; 00100 register int j; 00101 // use the number of input pixels derived from the length of the 'PixelData' 00102 // attribute), but not more than the size of the intermediate buffer 00103 const unsigned long count = (this->InputCount < this->Count) ? this->InputCount : this->Count; 00104 for (i = 0; i < count; ++i) 00105 { 00106 value = OFstatic_cast(T2, *(p++)); 00107 for (j = 0; j < 3; ++j) 00108 { 00109 if (value <= palette[j]->getFirstEntry(value)) 00110 this->Data[j][i] = OFstatic_cast(T3, palette[j]->getFirstValue()); 00111 else if (value >= palette[j]->getLastEntry(value)) 00112 this->Data[j][i] = OFstatic_cast(T3, palette[j]->getLastValue()); 00113 else 00114 this->Data[j][i] = OFstatic_cast(T3, palette[j]->getValue(value)); 00115 } 00116 } 00117 } 00118 } 00119 }; 00120 00121 00122 #endif 00123 00124 00125 /* 00126 * 00127 * CVS/RCS Log: 00128 * $Log: dipalpxt.h,v $ 00129 * Revision 1.24 2010-10-14 13:16:29 joergr 00130 * Updated copyright header. Added reference to COPYRIGHT file. 00131 * 00132 * Revision 1.23 2010-03-01 09:08:46 uli 00133 * Removed some unnecessary include directives in the headers. 00134 * 00135 * Revision 1.22 2009-11-25 14:31:21 joergr 00136 * Removed inclusion of header file "ofconsol.h". 00137 * 00138 * Revision 1.21 2009-10-14 10:25:14 joergr 00139 * Fixed minor issues in log output. Also updated copyright date (if required). 00140 * 00141 * Revision 1.20 2009-10-13 14:08:33 uli 00142 * Switched to logging mechanism provided by the "new" oflog module 00143 * 00144 * Revision 1.19 2006-08-15 16:35:01 meichel 00145 * Updated the code in module dcmimage to correctly compile when 00146 * all standard C++ classes remain in namespace std. 00147 * 00148 * Revision 1.18 2005/12/08 16:01:41 meichel 00149 * Changed include path schema for all DCMTK header files 00150 * 00151 * Revision 1.17 2004/04/21 10:00:31 meichel 00152 * Minor modifications for compilation with gcc 3.4.0 00153 * 00154 * Revision 1.16 2003/12/23 11:50:30 joergr 00155 * Adapted type casts to new-style typecast operators defined in ofcast.h. 00156 * Removed leading underscore characters from preprocessor symbols (reserved 00157 * symbols). Updated copyright header. 00158 * Replaced post-increment/decrement operators by pre-increment/decrement 00159 * operators where appropriate (e.g. 'i++' by '++i'). 00160 * 00161 * Revision 1.15 2002/06/26 16:19:13 joergr 00162 * Enhanced handling of corrupted pixel data and/or length. 00163 * Corrected decoding of multi-frame, planar images. 00164 * 00165 * Revision 1.14 2001/11/09 16:47:02 joergr 00166 * Removed 'inline' specifier from certain methods. 00167 * 00168 * Revision 1.13 2001/06/01 15:49:31 meichel 00169 * Updated copyright header 00170 * 00171 * Revision 1.12 2000/04/27 13:15:14 joergr 00172 * Dcmimage library code now consistently uses ofConsole for error output. 00173 * 00174 * Revision 1.11 2000/03/08 16:21:53 meichel 00175 * Updated copyright header. 00176 * 00177 * Revision 1.10 1999/09/17 14:03:45 joergr 00178 * Enhanced efficiency of some "for" loops. 00179 * 00180 * Revision 1.9 1999/05/03 11:03:06 joergr 00181 * Minor code purifications to keep Sun CC 2.0.1 quiet. 00182 * 00183 * Revision 1.8 1999/04/28 12:52:01 joergr 00184 * Corrected some typos, comments and formatting. 00185 * 00186 * Revision 1.7 1999/01/20 14:46:30 joergr 00187 * Replaced invocation of getCount() by member variable Count where possible. 00188 * 00189 * Revision 1.6 1998/12/14 17:08:56 joergr 00190 * Added support for signed values as second entry in look-up tables 00191 * (= first value mapped). 00192 * 00193 * Revision 1.5 1998/11/27 14:17:31 joergr 00194 * Added copyright message. 00195 * 00196 * Revision 1.4 1998/07/01 08:39:27 joergr 00197 * Minor changes to avoid compiler warnings (gcc 2.8.1 with additional 00198 * options), e.g. add copy constructors. 00199 * 00200 * Revision 1.3 1998/05/11 14:53:27 joergr 00201 * Added CVS/RCS header to each file. 00202 * 00203 * 00204 */