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


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