dcmimage/include/dcmtk/dcmimage/dicorot.h

00001 /*
00002  *
00003  *  Copyright (C) 1998-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:  dcmimgle
00015  *
00016  *  Author:  Joerg Riesmeier
00017  *
00018  *  Purpose: DicomColorRotateTemplate (Header)
00019  *
00020  *  Last Update:      $Author: joergr $
00021  *  Update Date:      $Date: 2010-10-14 13:16:29 $
00022  *  CVS/RCS Revision: $Revision: 1.15 $
00023  *  Status:           $State: Exp $
00024  *
00025  *  CVS/RCS Log at end of file
00026  *
00027  */
00028 
00029 
00030 #ifndef DICOROT_H
00031 #define DICOROT_H
00032 
00033 #include "dcmtk/config/osconfig.h"
00034 
00035 #include "dcmtk/dcmimage/dicopxt.h"
00036 #include "dcmtk/dcmimgle/dirotat.h"
00037 
00038 
00039 /*---------------------*
00040  *  class declaration  *
00041  *---------------------*/
00042 
00046 template<class T>
00047 class DiColorRotateTemplate
00048   : public DiColorPixelTemplate<T>,
00049     protected DiRotateTemplate<T>
00050 {
00051 
00052  public:
00053 
00064     DiColorRotateTemplate(const DiColorPixel *pixel,
00065                           const Uint16 src_cols,
00066                           const Uint16 src_rows,
00067                           const Uint16 dest_cols,
00068                           const Uint16 dest_rows,
00069                           const Uint32 frames,
00070                           const int degree)
00071       : DiColorPixelTemplate<T>(pixel, OFstatic_cast(unsigned long, dest_cols) * OFstatic_cast(unsigned long, dest_rows) * frames),
00072         DiRotateTemplate<T>(3, src_cols, src_rows, dest_cols, dest_rows, frames)
00073     {
00074         if ((pixel != NULL) && (pixel->getCount() > 0))
00075         {
00076             if (pixel->getCount() == OFstatic_cast(unsigned long, src_cols) * OFstatic_cast(unsigned long, src_rows) * frames)
00077                 rotate(OFstatic_cast(const T **, OFconst_cast(void *, pixel->getData())), degree);
00078             else {
00079                 DCMIMAGE_WARN("could not rotate image ... corrupted data");
00080             }
00081         }
00082     }
00083 
00086     ~DiColorRotateTemplate()
00087     {
00088     }
00089 
00090 
00091  private:
00092 
00098     inline void rotate(const T *pixel[3],
00099                        const int degree)
00100     {
00101         if (Init(pixel))
00102         {
00103             if (degree == 90)
00104                 rotateRight(pixel, this->Data);
00105             else if (degree == 180)
00106                 rotateTopDown(pixel, this->Data);
00107             else  if (degree == 270)
00108                 rotateLeft(pixel, this->Data);
00109         }
00110     }
00111 };
00112 
00113 
00114 #endif
00115 
00116 
00117 /*
00118  *
00119  * CVS/RCS Log:
00120  * $Log: dicorot.h,v $
00121  * Revision 1.15  2010-10-14 13:16:29  joergr
00122  * Updated copyright header. Added reference to COPYRIGHT file.
00123  *
00124  * Revision 1.14  2010-03-01 09:08:46  uli
00125  * Removed some unnecessary include directives in the headers.
00126  *
00127  * Revision 1.13  2009-10-14 10:25:13  joergr
00128  * Fixed minor issues in log output. Also updated copyright date (if required).
00129  *
00130  * Revision 1.12  2009-10-13 14:08:33  uli
00131  * Switched to logging mechanism provided by the "new" oflog module
00132  *
00133  * Revision 1.11  2006-08-15 16:35:01  meichel
00134  * Updated the code in module dcmimage to correctly compile when
00135  *   all standard C++ classes remain in namespace std.
00136  *
00137  * Revision 1.10  2005/12/08 16:01:36  meichel
00138  * Changed include path schema for all DCMTK header files
00139  *
00140  * Revision 1.9  2004/04/21 10:00:31  meichel
00141  * Minor modifications for compilation with gcc 3.4.0
00142  *
00143  * Revision 1.8  2004/02/06 11:18:18  joergr
00144  * Distinguish more clearly between const and non-const access to pixel data.
00145  *
00146  * Revision 1.7  2003/12/23 11:44:32  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  *
00151  * Revision 1.6  2001/11/09 16:45:00  joergr
00152  * Updated/Enhanced comments.
00153  *
00154  * Revision 1.5  2001/06/01 15:49:30  meichel
00155  * Updated copyright header
00156  *
00157  * Revision 1.4  2000/12/08 14:06:01  joergr
00158  * Added new checking routines to avoid crashes when processing corrupted image
00159  * data.
00160  *
00161  * Revision 1.3  2000/03/08 16:21:51  meichel
00162  * Updated copyright header.
00163  *
00164  * Revision 1.2  1999/04/28 12:51:59  joergr
00165  * Corrected some typos, comments and formatting.
00166  *
00167  * Revision 1.1  1998/11/27 14:59:36  joergr
00168  * Added copyright message.
00169  * Added methods and classes for flipping and rotating, changed for
00170  * scaling and clipping.
00171  *
00172  *
00173  */


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