From 6a5de9524996d429cd18c722261421ff4e298681 Mon Sep 17 00:00:00 2001 From: jpr Date: Fri, 24 Aug 2007 10:45:18 +0000 Subject: [PATCH] Fix comments --- src/gdcmFile.cxx | 5 +++-- src/gdcmFileHelper.cxx | 32 +++++++++++++++++++++----------- src/gdcmFileHelper.h | 6 ++++-- src/gdcmPixelWriteConvert.cxx | 12 +++++------- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 2cc7443f..0d1072a0 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -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) diff --git a/src/gdcmFileHelper.cxx b/src/gdcmFileHelper.cxx index 8f0acf34..997c37a2 100644 --- a/src/gdcmFileHelper.cxx +++ b/src/gdcmFileHelper.cxx @@ -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) { diff --git a/src/gdcmFileHelper.h b/src/gdcmFileHelper.h index 2e215d55..d59ee384 100644 --- a/src/gdcmFileHelper.h +++ b/src/gdcmFileHelper.h @@ -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; diff --git a/src/gdcmPixelWriteConvert.cxx b/src/gdcmPixelWriteConvert.cxx index ffa08cc3..00a3fbf2 100644 --- a/src/gdcmPixelWriteConvert.cxx +++ b/src/gdcmPixelWriteConvert.cxx @@ -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; -- 2.45.1