GDCM
2.0.18
|
00001 /*========================================================================= 00002 00003 Program: GDCM (Grassroots DICOM). A DICOM library 00004 00005 Copyright (c) 2006-2011 Mathieu Malaterre 00006 All rights reserved. 00007 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. 00008 00009 This software is distributed WITHOUT ANY WARRANTY; without even 00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00011 PURPOSE. See the above copyright notice for more information. 00012 00013 =========================================================================*/ 00014 #ifndef GDCMIMAGECHANGEPLANARCONFIGURATION_H 00015 #define GDCMIMAGECHANGEPLANARCONFIGURATION_H 00016 00017 #include "gdcmImageToImageFilter.h" 00018 00019 namespace gdcm 00020 { 00021 00022 class DataElement; 00028 class GDCM_EXPORT ImageChangePlanarConfiguration : public ImageToImageFilter 00029 { 00030 public: 00031 ImageChangePlanarConfiguration():PlanarConfiguration(0) {} 00032 ~ImageChangePlanarConfiguration() {} 00033 00035 void SetPlanarConfiguration(unsigned int pc) { PlanarConfiguration = pc; } 00036 unsigned int GetPlanarConfiguration() const { return PlanarConfiguration; } 00037 00040 template <typename T> 00041 static size_t RGBPlanesToRGBPixels(T *out, const T *r, const T *g, const T *b, size_t s); 00042 00046 template <typename T> 00047 static size_t RGBPixelsToRGBPlanes(T *r, T *g, T *b, const T* rgb, size_t s); 00048 00050 bool Change(); 00051 00052 protected: 00053 00054 private: 00055 unsigned int PlanarConfiguration; 00056 }; 00057 00058 template <typename T> 00059 size_t ImageChangePlanarConfiguration::RGBPlanesToRGBPixels(T *out, const T *r, const T *g, const T *b, size_t s) 00060 { 00061 T *pout = out; 00062 for(size_t i = 0; i < s; ++i ) 00063 { 00064 *pout++ = *r++; 00065 *pout++ = *g++; 00066 *pout++ = *b++; 00067 } 00068 00069 assert( (size_t)(pout - out) == 3 * s * sizeof(T) ); 00070 return pout - out; 00071 } 00072 00073 template <typename T> 00074 size_t ImageChangePlanarConfiguration::RGBPixelsToRGBPlanes(T *r, T *g, T *b, const T *rgb, size_t s) 00075 { 00076 const T *prgb = rgb; 00077 for(size_t i = 0; i < s; ++i ) 00078 { 00079 *r++ = *prgb++; 00080 *g++ = *prgb++; 00081 *b++ = *prgb++; 00082 } 00083 assert( (size_t)(prgb - rgb) == 3 * s * sizeof(T) ); 00084 return prgb - rgb; 00085 } 00086 00087 00088 } // end namespace gdcm 00089 00090 #endif //GDCMIMAGECHANGEPLANARCONFIGURATION_H