# gdcmImageChangePlanarConfiguration.h

Go to the documentation of this file.

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