dcmimage/include/dcmtk/dcmimage/dirgbpxt.h

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: DicomRGBPixelTemplate (Header)
00019  *
00020  *  Last Update:      $Author: joergr $
00021  *  Update Date:      $Date: 2010-10-14 13:16:30 $
00022  *  CVS/RCS Revision: $Revision: 1.18 $
00023  *  Status:           $State: Exp $
00024  *
00025  *  CVS/RCS Log at end of file
00026  *
00027  */
00028 
00029 
00030 #ifndef DIRGBPXT_H
00031 #define DIRGBPXT_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 DiRGBPixelTemplate
00047   : public DiColorPixelTemplate<T2>
00048 {
00049 
00050  public:
00051 
00060     DiRGBPixelTemplate(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, 3, 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 ~DiRGBPixelTemplate()
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 T1 offset = OFstatic_cast(T1, DicomImageClass::maxval(bits - 1));
00096             register const T1 *p = pixel;
00097             if (this->PlanarConfiguration)
00098             {
00099 /*
00100                 register T2 *q;
00101                 // number of pixels to be skipped (only applicable if 'PixelData' contains more
00102                 // pixels than expected)
00103                 const unsigned long skip = (this->InputCount > this->Count) ? (this->InputCount - this->Count) : 0;
00104                 for (int j = 0; j < 3; ++j)
00105                 {
00106                     q = this->Data[j];
00107                     for (i = count; i != 0; --i)
00108                         *(q++) = removeSign(*(p++), offset);
00109                     // skip to beginning of next plane
00110                     p += skip;
00111                 }
00112 */
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                     /* for all planes ... */
00120                     for (int j = 0; j < 3; ++j)
00121                     {
00122                         /* convert a single plane */
00123                         for (l = planeSize, i = iStart; (l != 0) && (i < count); --l, ++i)
00124                             this->Data[j][i] = removeSign(*(p++), offset);
00125                     }
00126                 }
00127             }
00128             else
00129             {
00130                 register int j;
00131                 register unsigned long i;
00132                 for (i = 0; i < count; ++i)                         /* for all pixel ... */
00133                     for (j = 0; j < 3; ++j)
00134                         this->Data[j][i] = removeSign(*(p++), offset);    /* ... copy planes */
00135             }
00136         }
00137     }
00138 };
00139 
00140 
00141 #endif
00142 
00143 
00144 /*
00145  *
00146  * CVS/RCS Log:
00147  * $Log: dirgbpxt.h,v $
00148  * Revision 1.18  2010-10-14 13:16:30  joergr
00149  * Updated copyright header. Added reference to COPYRIGHT file.
00150  *
00151  * Revision 1.17  2005/12/08 16:01:59  meichel
00152  * Changed include path schema for all DCMTK header files
00153  *
00154  * Revision 1.16  2004/04/21 10:00:31  meichel
00155  * Minor modifications for compilation with gcc 3.4.0
00156  *
00157  * Revision 1.15  2003/12/23 12:24:23  joergr
00158  * Adapted type casts to new-style typecast operators defined in ofcast.h.
00159  * Removed leading underscore characters from preprocessor symbols (reserved
00160  * symbols). Updated copyright header.
00161  * Replaced post-increment/decrement operators by pre-increment/decrement
00162  * operators where appropriate (e.g. 'i++' by '++i').
00163  *
00164  * Revision 1.14  2002/06/26 16:19:46  joergr
00165  * Enhanced handling of corrupted pixel data and/or length.
00166  * Corrected decoding of multi-frame, planar images.
00167  *
00168  * Revision 1.13  2001/11/09 16:47:02  joergr
00169  * Removed 'inline' specifier from certain methods.
00170  *
00171  * Revision 1.12  2001/06/01 15:49:32  meichel
00172  * Updated copyright header
00173  *
00174  * Revision 1.11  2000/04/27 13:15:14  joergr
00175  * Dcmimage library code now consistently uses ofConsole for error output.
00176  *
00177  * Revision 1.10  2000/03/08 16:21:53  meichel
00178  * Updated copyright header.
00179  *
00180  * Revision 1.9  1999/09/17 14:03:46  joergr
00181  * Enhanced efficiency of some "for" loops.
00182  *
00183  * Revision 1.8  1999/04/28 12:52:02  joergr
00184  * Corrected some typos, comments and formatting.
00185  *
00186  * Revision 1.7  1999/02/03 16:54:27  joergr
00187  * Moved global functions maxval() and determineRepresentation() to class
00188  * DicomImageClass (as static methods).
00189  *
00190  * Revision 1.6  1999/01/20 14:46:39  joergr
00191  * Replaced invocation of getCount() by member variable Count where possible.
00192  *
00193  * Revision 1.5  1998/11/27 14:18:18  joergr
00194  * Added copyright message.
00195  *
00196  * Revision 1.4  1998/05/11 14:53:29  joergr
00197  * Added CVS/RCS header to each file.
00198  *
00199  *
00200  */


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1