00001 /* 00002 * 00003 * Copyright (C) 1996-2005, OFFIS 00004 * 00005 * This software and supporting documentation were developed by 00006 * 00007 * Kuratorium OFFIS e.V. 00008 * Healthcare Information and Communication Systems 00009 * Escherweg 2 00010 * D-26121 Oldenburg, Germany 00011 * 00012 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 00013 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 00014 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 00015 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 00016 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 00017 * 00018 * Module: dcmimage 00019 * 00020 * Author: Joerg Riesmeier 00021 * 00022 * Purpose: DicomCMYKPixelTemplate (Header) 00023 * 00024 * Last Update: $Author: meichel $ 00025 * Update Date: $Date: 2005/12/08 16:01:27 $ 00026 * CVS/RCS Revision: $Revision: 1.19 $ 00027 * Status: $State: Exp $ 00028 * 00029 * CVS/RCS Log at end of file 00030 * 00031 */ 00032 00033 00034 #ifndef DICMYPXT_H 00035 #define DICMYPXT_H 00036 00037 #include "dcmtk/config/osconfig.h" 00038 00039 #include "dcmtk/dcmimage/dicopxt.h" 00040 #include "dcmtk/dcmimgle/diinpx.h" /* gcc 3.4 needs this */ 00041 00042 00043 /*---------------------* 00044 * class declaration * 00045 *---------------------*/ 00046 00049 template<class T1, class T2> 00050 class DiCMYKPixelTemplate 00051 : public DiColorPixelTemplate<T2> 00052 { 00053 00054 public: 00055 00064 DiCMYKPixelTemplate(const DiDocument *docu, 00065 const DiInputPixel *pixel, 00066 EI_Status &status, 00067 const unsigned long planeSize, 00068 const int bits) 00069 : DiColorPixelTemplate<T2>(docu, pixel, 4, status) 00070 { 00071 if ((pixel != NULL) && (this->Count > 0) && (status == EIS_Normal)) 00072 convert(OFstatic_cast(const T1 *, pixel->getData()) + pixel->getPixelStart(), planeSize, bits); 00073 } 00074 00077 virtual ~DiCMYKPixelTemplate() 00078 { 00079 } 00080 00081 00082 private: 00083 00090 void convert(const T1 *pixel, 00091 const unsigned long planeSize, 00092 const int bits) 00093 { 00094 if (Init(pixel)) 00095 { 00096 // use the number of input pixels derived from the length of the 'PixelData' 00097 // attribute), but not more than the size of the intermediate buffer 00098 const unsigned long count = (this->InputCount < this->Count) ? this->InputCount : this->Count; 00099 const T2 maxvalue = OFstatic_cast(T2, DicomImageClass::maxval(bits)); 00100 const T1 offset = OFstatic_cast(T1, DicomImageClass::maxval(bits - 1)); 00101 register const T1 *p = pixel; 00102 if (this->PlanarConfiguration) 00103 { 00104 /* 00105 register const T1 *k; 00106 register T2 *q; 00107 for (int j = 0; j < 3; ++j) 00108 { 00109 q = this->Data[j]; 00110 k = pixel + 3 * this->InputCount; // beginning of 'black' plane 00111 for (i = count; i != 0; --i) 00112 *(q++) = maxvalue - removeSign(*(p++), offset) - removeSign(*(k++), offset); 00113 } 00114 */ 00115 register const T1 *k; 00116 register T2 *q; 00117 register unsigned long l; 00118 register unsigned long i = 0; 00119 while (i < count) 00120 { 00121 /* store current pixel index */ 00122 const unsigned long iStart = i; 00123 /* beginning of 'black' plane */ 00124 const T1 *kStart = p + 3 * planeSize; 00125 /* for all planes ... */ 00126 for (int j = 0; j < 3; ++j) 00127 { 00128 q = this->Data[j] + iStart; 00129 /* reset to beginning of 'black' plane */ 00130 k = kStart; 00131 /* convert a single plane */ 00132 for (l = planeSize, i = iStart; (l != 0) && (i < count); --l, ++i) 00133 *(q++) = maxvalue - removeSign(*(p++), offset) - removeSign(*(k++), offset); 00134 } 00135 /* skip black plane */ 00136 p += planeSize; 00137 } 00138 } 00139 else 00140 { 00141 register T1 k; 00142 register int j; 00143 register unsigned long i; 00144 for (i = 0; i < count; ++i) 00145 { 00146 k = *(p + 3); 00147 for (j = 0; j < 3; ++j) 00148 this->Data[j][i] = maxvalue - removeSign(*(p++), offset) - removeSign(k, offset); 00149 ++p; // skip 'black' 00150 } 00151 } 00152 } 00153 } 00154 }; 00155 00156 00157 #endif 00158 00159 00160 /* 00161 * 00162 * CVS/RCS Log: 00163 * $Log: dicmypxt.h,v $ 00164 * Revision 1.19 2005/12/08 16:01:27 meichel 00165 * Changed include path schema for all DCMTK header files 00166 * 00167 * Revision 1.18 2004/04/21 10:00:31 meichel 00168 * Minor modifications for compilation with gcc 3.4.0 00169 * 00170 * Revision 1.17 2003/12/23 16:06:21 joergr 00171 * Replaced additional post-increment/decrement operators by pre-increment/ 00172 * decrement operators. 00173 * 00174 * Revision 1.16 2003/12/23 12:38:51 joergr 00175 * Replaced post-increment/decrement operators by pre-increment/decrement 00176 * operators where appropriate (e.g. 'i++' by '++i'). 00177 * 00178 * Revision 1.15 2003/12/23 11:17:23 joergr 00179 * Adapted type casts to new-style typecast operators defined in ofcast.h. 00180 * Removed leading underscore characters from preprocessor symbols (reserved 00181 * symbols). Updated copyright header. 00182 * 00183 * Revision 1.14 2002/06/26 16:16:38 joergr 00184 * Enhanced handling of corrupted pixel data and/or length. 00185 * Corrected decoding of multi-frame, planar images. 00186 * 00187 * Revision 1.13 2001/11/09 16:40:16 joergr 00188 * Removed 'inline' specifier from certain methods. 00189 * 00190 * Revision 1.12 2001/06/01 15:49:27 meichel 00191 * Updated copyright header 00192 * 00193 * Revision 1.11 2000/04/27 13:15:13 joergr 00194 * Dcmimage library code now consistently uses ofConsole for error output. 00195 * 00196 * Revision 1.10 2000/03/08 16:21:49 meichel 00197 * Updated copyright header. 00198 * 00199 * Revision 1.9 1999/09/17 14:03:42 joergr 00200 * Enhanced efficiency of some "for" loops. 00201 * 00202 * Revision 1.8 1999/04/28 12:51:56 joergr 00203 * Corrected some typos, comments and formatting. 00204 * 00205 * Revision 1.7 1999/02/03 16:48:32 joergr 00206 * Moved global functions maxval() and determineRepresentation() to class 00207 * DicomImageClass (as static methods). 00208 * 00209 * Revision 1.6 1999/01/20 14:37:05 joergr 00210 * Replaced invocation of getCount() by member variable Count where possible. 00211 * 00212 * Revision 1.5 1998/11/27 13:41:04 joergr 00213 * Added copyright message. 00214 * 00215 * Revision 1.4 1998/05/11 14:53:10 joergr 00216 * Added CVS/RCS header to each file. 00217 * 00218 * 00219 */