+
+
+// --------------------------------------------------------
+// This is just a *very* simple example of user supplied function
+// to mirror (why not ?) the image
+// It's *not* part of gdcm.
+// --------------------------------------------------------
+
+#define UF(ty) \
+ int i, j; \
+ ty *imj; \
+ ty tamp; \
+ for (j=0;j<ny;j++) \
+ { \
+ imj = (ty *)im +j*nx; \
+ for (i=0;i<nx/2;i++) \
+ { \
+ tamp =imj[i]; \
+ imj[i] =imj[nx-1-i]; \
+ imj[nx-1-i]=tamp; \
+ } \
+ } \
+ if (nx%2 != 0) \
+ { \
+ for (j=0;j<ny;j++) \
+ { \
+ imj = (ty *)im +j*nx; \
+ tamp =imj[i]; \
+ imj[i] =imj[nx/2+1]; \
+ imj[nx/2+1]=tamp; \
+ } \
+ }
+
+void userSuppliedMirrorFunction(uint8_t *im, gdcm::File *f)
+{
+ if (f->GetZSize() != 1)
+ {
+ std::cout << "mirror : Multiframe images not yet dealt with" << std::endl;
+ return;
+ }
+
+ if (f->GetSamplesPerPixel() != 1 || f->GetBitsAllocated() == 24)
+ {
+ std::cout << "mirror : RGB / YBR not yet dealt with" << std::endl;
+ return;
+ }
+ int nx = f->GetXSize();
+ int ny = f->GetYSize();
+
+ std::string pixelType = f->GetPixelType();
+ if ( pixelType == "8U" || pixelType == "8S" )
+ {
+ UF(uint8_t)
+ return;
+ }
+ if ( pixelType == "16U" || pixelType == "16S")
+ {
+ UF(uint16_t)
+ return;
+ }
+ std::cout << "mirror : Pixel Size (!=8, !=16) not yet dealt with"
+ << std::endl;
+ return;
+}
+
+
+// --------------------------------------------------------
+// This is just a *very* simple example of user supplied function
+// to topdown (why not ?) the image
+// It's *not* part of gdcm.
+// --------------------------------------------------------
+
+#define UF2(ty) \
+ int i, j; \
+ ty *imj, *imJ; \
+ ty tamp; \
+ for (j=0;j<ny/2;j++) \
+ { \
+ imj = (ty *)im +j*nx; \
+ imJ = (ty *)im +(ny-1-j)*nx; \
+ for (i=0;i<nx;i++) \
+ { \
+ tamp =imj[i]; \
+ imj[i] =imJ[i]; \
+ imJ[i] =tamp; \
+ } \
+ }
+
+void userSuppliedTopDownFunction(uint8_t *im, gdcm::File *f)
+{
+ if (f->GetZSize() != 1)
+ {
+ std::cout << "mirror : Multiframe images not yet dealt with" << std::endl;
+ return;
+ }
+
+ if (f->GetSamplesPerPixel() != 1 || f->GetBitsAllocated() == 24)
+ {
+ std::cout << "mirror : RGB / YBR not yet dealt with" << std::endl;
+ return;
+ }
+ int nx = f->GetXSize();
+ int ny = f->GetYSize();
+
+ std::string pixelType = f->GetPixelType();
+ if ( pixelType == "8U" || pixelType == "8S" )
+ {
+ UF2(uint8_t)
+ return;
+ }
+ if ( pixelType == "16U" || pixelType == "16S")
+ {
+ UF2(uint16_t)
+ return;
+ }
+ std::cout << "topdown : Pixel Size (!=8, !=16) not yet dealt with"
+ << std::endl;
+ return;
+}
+
+
+
+