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