+ std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]"
+ << std::endl;
+
+ fh->SetKeepOverlays( keepoverlays );
+
+ if(monochrome1)
+ fh->SetPhotometricInterpretationToMonochrome1();
+
+ if (rgb)
+ {
+ dataSize = fh->GetImageDataSize();
+ imageData = fh->GetImageData(); // somewhat important : Loads the Pixels in memory !
+ fh->SetWriteModeToRGB();
+ }
+ else
+ {
+ dataSize = fh->GetImageDataRawSize();
+ imageData = fh->GetImageDataRaw();// somewhat important : Loads the Pixels in memory !
+ fh->SetWriteModeToRaw();
+ }
+
+ if ( imageData == 0 ) // to avoid warning
+ {
+ std::cout << "Was unable to read pixels " << std::endl;
+ }
+ printf(" dataSize %d imageData %p\n",dataSize, imageData);
+
+ // Since we just ReWrite the image, we know no modification
+ // was performed on the pixels.
+ // We don't want this image appears as a 'Secondary Captured image'
+ fh->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE);
+
+
+ /// \todo : think about rubbing out a part of a *multiframe* image!
+ if (rubout)
+ {
+ if (boundVal[0]<0 || boundVal[0]>nX)
+ {
+ std::cout << "xBegin out of bounds; 'rubout' ignored" << std::endl;
+ fail = true;
+ }
+ if (boundVal[1]<0 || boundVal[1]>nX)
+ {
+ std::cout << "xEnd out of bounds; 'rubout' ignored" << std::endl;
+ fail = true;
+ }
+ if (boundVal[0] > boundVal[1])
+ {
+ std::cout << "xBegin greater than xEnd; 'rubout' ignored" << std::endl;
+ fail = true;
+ }
+ if (boundVal[2]<0 || boundVal[2]>nY)
+ {
+ std::cout << "yBegin out of bounds; 'rubout' ignored" << std::endl;
+ fail = true;
+ }
+ if (boundVal[3]<0 || boundVal[3]>nY)
+ {
+ std::cout << "yEnd out of bounds; 'rubout' ignored" << std::endl;
+ fail = true;
+ }
+ if (boundVal[2] > boundVal[3])
+ {
+ std::cout << "yBegin greater than yEnd; 'rubout' ignored" << std::endl;
+ fail = true;
+ }
+ if (!fail)
+ {
+ int pixelLength = f->GetBitsAllocated()/8;
+ int lineLength = nX * sPP * pixelLength;
+ size_t lengthToRubout = (boundVal[1]-boundVal[0])*sPP*pixelLength;
+ int offsetToBeginOfRubout = boundVal[0]*sPP*pixelLength+lineLength*boundVal[2];
+
+ for(int rbl=boundVal[2]; rbl<boundVal[3];rbl++)
+ {
+ memset((char *)imageData+offsetToBeginOfRubout, ruboutVal, lengthToRubout);
+ offsetToBeginOfRubout += lineLength;
+ }
+ }
+ }
+
+
+//------------------------------ Set the Writing mode ---------------------------------