dipalpxt.h

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: DicomPalettePixelTemplate (Header)
00023  *
00024  *  Last Update:      $Author: meichel $
00025  *  Update Date:      $Date: 2005/12/08 16:01:41 $
00026  *  CVS/RCS Revision: $Revision: 1.18 $
00027  *  Status:           $State: Exp $
00028  *
00029  *  CVS/RCS Log at end of file
00030  *
00031  */
00032 
00033 
00034 #ifndef DIPALPXT_H
00035 #define DIPALPXT_H
00036 
00037 #include "dcmtk/config/osconfig.h"
00038 
00039 #include "dcmtk/ofstd/ofconsol.h"    /* for ofConsole */
00040 
00041 #include "dcmtk/dcmimage/dicopxt.h"
00042 #include "dcmtk/dcmimgle/diluptab.h"
00043 #include "dcmtk/dcmimgle/diinpx.h"  /* gcc 3.4 needs this */
00044 
00045 
00046 /*---------------------*
00047  *  class declaration  *
00048  *---------------------*/
00049 
00052 template<class T1, class T2, class T3>
00053 class DiPalettePixelTemplate
00054   : public DiColorPixelTemplate<T3>
00055 {
00056 
00057  public:
00058 
00066     DiPalettePixelTemplate(const DiDocument *docu,
00067                            const DiInputPixel *pixel,
00068                            DiLookupTable *palette[3],
00069                            EI_Status &status)
00070       : DiColorPixelTemplate<T3>(docu, pixel, 1, status)
00071     {
00072         if ((pixel != NULL) && (this->Count > 0) && (status == EIS_Normal))
00073         {
00074             if (this->PlanarConfiguration)
00075             {
00076                 status = EIS_InvalidValue;
00077                 if (DicomImageClass::checkDebugLevel(DicomImageClass::DL_Errors))
00078                 {
00079                     ofConsole.lockCerr() << "ERROR: invalid value for 'PlanarConfiguration' ("
00080                                          << this->PlanarConfiguration << ") ! " << endl;
00081                     ofConsole.unlockCerr();
00082                 }
00083             }
00084             else
00085                 convert(OFstatic_cast(const T1 *, pixel->getData()) + pixel->getPixelStart(), palette);
00086         }
00087     }
00088 
00091     virtual ~DiPalettePixelTemplate()
00092     {
00093     }
00094 
00095 
00096  private:
00097 
00103     void convert(const T1 *pixel,
00104                  DiLookupTable *palette[3])
00105     {                                                                // can be optimized if necessary !
00106         if (Init(pixel))
00107         {
00108             register const T1 *p = pixel;
00109             register T2 value = 0;
00110             register unsigned long i;
00111             register int j;
00112             // use the number of input pixels derived from the length of the 'PixelData'
00113             // attribute), but not more than the size of the intermediate buffer
00114             const unsigned long count = (this->InputCount < this->Count) ? this->InputCount : this->Count;
00115             for (i = 0; i < count; ++i)
00116             {
00117                 value = OFstatic_cast(T2, *(p++));
00118                 for (j = 0; j < 3; ++j)
00119                 {
00120                     if (value <= palette[j]->getFirstEntry(value))
00121                         this->Data[j][i] = OFstatic_cast(T3, palette[j]->getFirstValue());
00122                     else if (value >= palette[j]->getLastEntry(value))
00123                         this->Data[j][i] = OFstatic_cast(T3, palette[j]->getLastValue());
00124                     else
00125                         this->Data[j][i] = OFstatic_cast(T3, palette[j]->getValue(value));
00126                 }
00127             }
00128         }
00129     }
00130 };
00131 
00132 
00133 #endif
00134 
00135 
00136 /*
00137  *
00138  * CVS/RCS Log:
00139  * $Log: dipalpxt.h,v $
00140  * Revision 1.18  2005/12/08 16:01:41  meichel
00141  * Changed include path schema for all DCMTK header files
00142  *
00143  * Revision 1.17  2004/04/21 10:00:31  meichel
00144  * Minor modifications for compilation with gcc 3.4.0
00145  *
00146  * Revision 1.16  2003/12/23 11:50:30  joergr
00147  * Adapted type casts to new-style typecast operators defined in ofcast.h.
00148  * Removed leading underscore characters from preprocessor symbols (reserved
00149  * symbols). Updated copyright header.
00150  * Replaced post-increment/decrement operators by pre-increment/decrement
00151  * operators where appropriate (e.g. 'i++' by '++i').
00152  *
00153  * Revision 1.15  2002/06/26 16:19:13  joergr
00154  * Enhanced handling of corrupted pixel data and/or length.
00155  * Corrected decoding of multi-frame, planar images.
00156  *
00157  * Revision 1.14  2001/11/09 16:47:02  joergr
00158  * Removed 'inline' specifier from certain methods.
00159  *
00160  * Revision 1.13  2001/06/01 15:49:31  meichel
00161  * Updated copyright header
00162  *
00163  * Revision 1.12  2000/04/27 13:15:14  joergr
00164  * Dcmimage library code now consistently uses ofConsole for error output.
00165  *
00166  * Revision 1.11  2000/03/08 16:21:53  meichel
00167  * Updated copyright header.
00168  *
00169  * Revision 1.10  1999/09/17 14:03:45  joergr
00170  * Enhanced efficiency of some "for" loops.
00171  *
00172  * Revision 1.9  1999/05/03 11:03:06  joergr
00173  * Minor code purifications to keep Sun CC 2.0.1 quiet.
00174  *
00175  * Revision 1.8  1999/04/28 12:52:01  joergr
00176  * Corrected some typos, comments and formatting.
00177  *
00178  * Revision 1.7  1999/01/20 14:46:30  joergr
00179  * Replaced invocation of getCount() by member variable Count where possible.
00180  *
00181  * Revision 1.6  1998/12/14 17:08:56  joergr
00182  * Added support for signed values as second entry in look-up tables
00183  * (= first value mapped).
00184  *
00185  * Revision 1.5  1998/11/27 14:17:31  joergr
00186  * Added copyright message.
00187  *
00188  * Revision 1.4  1998/07/01 08:39:27  joergr
00189  * Minor changes to avoid compiler warnings (gcc 2.8.1 with additional
00190  * options), e.g. add copy constructors.
00191  *
00192  * Revision 1.3  1998/05/11 14:53:27  joergr
00193  * Added CVS/RCS header to each file.
00194  *
00195  *
00196  */


Generated on 20 Dec 2005 for OFFIS DCMTK Version 3.5.4 by Doxygen 1.4.5