]> Creatis software - gdcm.git/commitdiff
Fix comments
authorjpr <jpr>
Fri, 24 Aug 2007 10:45:18 +0000 (10:45 +0000)
committerjpr <jpr>
Fri, 24 Aug 2007 10:45:18 +0000 (10:45 +0000)
src/gdcmFile.cxx
src/gdcmFileHelper.cxx
src/gdcmFileHelper.h
src/gdcmPixelWriteConvert.cxx

index 2cc7443f9acffc925463e4c90bd9b2c525df6a99..0d1072a0db2b98ae629aec819a1303f5b4a327bb 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/08/22 16:14:04 $
-  Version:   $Revision: 1.334 $
+  Date:      $Date: 2007/08/24 10:45:18 $
+  Version:   $Revision: 1.335 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -1978,6 +1978,7 @@ bool File::AnonymizeFile()
  */
 bool File::Write(std::string fileName, FileType writetype)
 {
+      gdcmDebugMacro(" File::Write ");
    std::ofstream *fp = new std::ofstream(fileName.c_str(), 
                                          std::ios::out | std::ios::binary);
    if (*fp == NULL)
index 8f0acf34201f12bf5affa6cc2a18ef59f02c05b2..997c37a24772dc16733a61a46240930eb1092e2b 100644 (file)
@@ -4,8 +4,8 @@
   Module:    $RCSfile: gdcmFileHelper.cxx,v $
   Language:  C++
 
-  Date:      $Date: 2007/08/21 12:51:09 $
-  Version:   $Revision: 1.120 $
+  Date:      $Date: 2007/08/24 10:45:18 $
+  Version:   $Revision: 1.121 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -63,15 +63,17 @@ std::string v = f->GetEntryValue(groupNb,ElementNb);
 
 // to get the pixels, user needs a gdcm::FileHelper
 gdcm::FileHelper *fh = new gdcm::FileHelper(f);
+
 // user may ask not to convert Palette (if any) to RGB
 uint8_t *pixels = fh->GetImageDataRaw();
 int imageLength = fh->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
+//To re-write the image, user re-uses the gdcm::FileHelper
+gdcm::File *fh = new gdcm::FileHelper();
 
-fh->SetImageData( userPixels, userPixelsLength);
 fh->SetTypeToRaw(); // Even if it was possible to convert Palette to RGB
                     // (WriteMode is set)
 
@@ -79,14 +81,20 @@ fh->SetTypeToRaw(); // Even if it was possible to convert Palette to RGB
 fh->SetPhotometricInterpretationToMonochrome1();
 
 fh->SetWriteTypeToDcmExpl();  // he wants Explicit Value Representation
-                              // Little Endian is the default
-                              // no other value is allowed
+                              // Little Endian is the default,
+                              // bigendian not supported for writting
                                 (-->SetWriteType(ExplicitVR);)
                                    -->WriteType = ExplicitVR;
+fh->SetWriteTypeToJPEG();     // lossless compression   
+fh->SetWriteTypeToJPEG2000(); // lossless compression   
+
+fh->SetImageData( userPixels, userPixelsLength);
+or
+fh->SetUserData( userPixels, userPixelsLength); // this one performs compression, when required
+   
 fh->Write(newFileName);      // overwrites the file, if any
 
-// or :
-fh->WriteDcmExplVR(newFileName);
+
 
 
 // ----------------------------- WARNING -------------------------
@@ -494,7 +502,7 @@ size_t FileHelper::GetImageDataIntoVector (void *destination, size_t maxSize)
  *          not to deallocate its data before gdcm uses them (e.g. with
  *          the Write() method )
  * @param inData user supplied pixel area (uint8_t* is just for the compiler.
- *               user is allowed to pass any kind of pixelsn since the size is
+ *               user is allowed to pass any kind of pixels since the size is
  *               given in bytes) 
  * @param expectedSize total image size, *in Bytes*
  */
@@ -706,7 +714,7 @@ bool FileHelper::WriteAcr (std::string const &fileName)
  * @return false if write fails
  */
 bool FileHelper::Write(std::string const &fileName)
-{
+{ 
    CheckMandatoryElements(); //called once, here !
    
    bool flag = false;
@@ -808,9 +816,11 @@ bool FileHelper::Write(std::string const &fileName)
          break;
    }
 
-   bool check = CheckWriteIntegrity(); // verifies length
+   bool check;
    if (WriteType == JPEG || WriteType == JPEG2000)
       check = true;
+   else
+      check = CheckWriteIntegrity(); // verifies length
 
    if (check)
    {
index 2e215d55275f9684345266ae66d1325070536e2c..d59ee3842ca21f9f37cacc1609deb0215d419f15 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFileHelper.h,v $
   Language:  C++
-  Date:      $Date: 2007/08/22 16:14:04 $
-  Version:   $Revision: 1.52 $
+  Date:      $Date: 2007/08/24 10:45:18 $
+  Version:   $Revision: 1.53 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -234,8 +234,10 @@ private:
    bool Parsed;
 
    // Utility pixel converter
+   
    /// \brief Pointer to the PixelReadConverter
    PixelReadConvert *PixelReadConverter;
+   
    /// \brief Pointer to the PixelWriteConverter
    PixelWriteConvert *PixelWriteConverter;
 
index ffa08cc3ed244a993febae1e122995e8de0200c6..00a3fbf25c6b9df7abdcb6f850cf9144a6ffe01f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmPixelWriteConvert.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/08/22 16:14:04 $
-  Version:   $Revision: 1.16 $
+  Date:      $Date: 2007/08/24 10:45:18 $
+  Version:   $Revision: 1.17 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -55,6 +55,7 @@ PixelWriteConvert::PixelWriteConvert()
  */
 PixelWriteConvert::~PixelWriteConvert() 
 {
+   gdcmDebugMacro("PixelWriteConvert::~PixelWriteConvert()" );
    if( Compressed )
      {
      delete[] UserData;
@@ -309,9 +310,6 @@ bool gdcm_write_JPEG_file16 (std::ostream *fp, char *inputdata, size_t inputleng
 
 void PixelWriteConvert::SetCompressJPEGUserData(uint8_t *data, size_t size, File *image)
 {
-
- std::cerr << "entree ds PixelWriteConvert::SetCompressJPEGUserData" << std::endl; 
   (void)data;
   (void)size;
   (void)image;
@@ -320,8 +318,8 @@ void PixelWriteConvert::SetCompressJPEGUserData(uint8_t *data, size_t size, File
 
    std::ostringstream *of = new std::ostringstream();
     int xsize = image->GetXSize();
-   int ysize = image->GetYSize();
-  int zsize =  image->GetZSize();
+    int ysize = image->GetYSize();
+    int zsize = image->GetZSize();
     int samplesPerPixel = image->GetSamplesPerPixel();
    //std::cout << "X: " << xsize << std::endl;
    //std::cout << "Y: " << ysize << std::endl;