]> Creatis software - gdcm.git/blobdiff - src/gdcmFileHelper.cxx
To avoid valgring warning about shadowed local variable
[gdcm.git] / src / gdcmFileHelper.cxx
index 1136dc0d48941286b8fe4bf1075b3ed24761c269..c1e1c31147701558d0549b335447a63606a52924 100644 (file)
@@ -4,8 +4,8 @@
   Module:    $RCSfile: gdcmFileHelper.cxx,v $
   Language:  C++
 
-  Date:      $Date: 2005/03/02 17:18:32 $
-  Version:   $Revision: 1.22 $
+  Date:      $Date: 2005/03/04 09:45:04 $
+  Version:   $Revision: 1.25 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 
 #include <fstream>
 
+/*
+// ----------------------------- WARNING -------------------------
+
+These lines will be moved to the document-to-be 'User's Guide'
+
+// To read an image, user needs a gdcm::File
+gdcm::File *f1 = new gdcm::File(fileName);
+// user can now check some values
+std::string v = f1->GetEntryValue(groupNb,ElementNb);
+// to get the pixels, user needs a gdcm::FileHelper
+gdcm::FileHelper *fh1 = new gdcm::FileHelper(f1);
+// user may ask not to convert Palette to RGB
+uint8_t *pixels = fh1->GetImageDataRaw();
+int imageLength = fh1->GetImageDataRawSize();
+// He can now use the pixels, create a new image, ...
+uint8_t *userPixels = ...
+
+To re-write the image, user re-uses the gdcm::FileHelper
+
+fh1->SetImageData( userPixels, userPixelsLength);
+fh1->SetTypeToRaw(); // Even if it was possible to convert Palette to RGB
+                     // (WriteMode is set)
+fh1->SetWriteTypeToDcmExpl(); // he wants Explicit Value Representation
+                              // Little Endian is the default
+                              // no other value is allowed
+                                (-->SetWriteType(ExplicitVR);)
+                                   -->WriteType = ExplicitVR;
+fh1->Write(newFileName);      // overwrites the file, if any
+
+// or :
+fh1->WriteDcmExplVR(newFileName);
+
+
+// ----------------------------- WARNING -------------------------
+
+These lines will be moved to the document-to-be 'Developer's Guide'
+
+WriteMode : WMODE_RAW / WMODE_RGB
+WriteType : ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO
+
+fh1->Write(newFileName);
+   SetWriteFileTypeToImplicitVR() / SetWriteFileTypeToExplicitVR();
+   (modifies TransferSyntax)
+   SetWriteToRaw(); / SetWriteToRGB();
+      (modifies, when necessary : photochromatic interpretation, 
+         samples per pixel, Planar configuration, 
+         bits allocated, bits stored, high bit -ACR 24 bits-
+         Pixels element VR, pushes out the LUT )
+   CheckWriteIntegrity();
+      (checks user given pixels length)
+   FileInternal->Write(fileName,WriteType)
+   fp = opens file(fileName);
+   ComputeGroup0002Length(writetype);
+   BitsAllocated 12->16
+      RemoveEntryNoDestroy(palettes, etc)
+      Document::WriteContent(fp, writetype);
+   RestoreWrite();
+      (moves back to the File all the archived elements)
+   RestoreWriteFileType();
+      (pushes back group 0002, with TransferSyntax)
+*/
+
+
+
+
 namespace gdcm 
 {
 //-------------------------------------------------------------------------
@@ -1018,7 +1084,7 @@ BinEntry *FileHelper::CopyBinEntry(uint16_t group, uint16_t elem,
  *             - we push the sensitive entries to the Archive
  *          The writing process will restore the entries as they where before 
  *          entering FileHelper::CheckMandatoryElements, so the user will always
- *          see the entries just as he
+ *          see the entries just as he left them.
  * 
  * \todo : - warn the user if we had to add some entries :
  *         even if a mandatory entry is missing, we add it, with a default value
@@ -1137,7 +1203,7 @@ void FileHelper::CheckMandatoryElements()
       // the source image was NOT a true Dicom one.
       // We consider the image is a 'Secondary Capture' one
       // SOP Class UID
-      ValEntry *e_0008_0016  =  new ValEntry( 
+      e_0008_0016  =  new ValEntry( 
             Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x0016) );
       // [Secondary Capture Image Storage]
       e_0008_0016 ->SetValue("1.2.840.10008.5.1.4.1.1.7"); 
@@ -1284,9 +1350,9 @@ void FileHelper::CheckMandatoryElements()
  
    // Remove some inconstencies (probably some more will be added)
 
-   // Push out (0020 0052),Frame of Reference UID
    // if (0028 0008)Number of Frames exists
-   // (0020 0052),Frame of Reference UID only meaningfull within a Serie
+   //    Push out (0020 0052),Frame of Reference UID
+   //    (only meaningfull within a Serie)
    ValEntry *e_0028_0008 = FileInternal->GetValEntry(0x0028, 0x0008);
    if ( !e_0028_0008 )
    {