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
*/
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)
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
// 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)
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 -------------------------
* 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*
*/
* @return false if write fails
*/
bool FileHelper::Write(std::string const &fileName)
-{
+{
CheckMandatoryElements(); //called once, here !
bool flag = false;
break;
}
- bool check = CheckWriteIntegrity(); // verifies length
+ bool check;
if (WriteType == JPEG || WriteType == JPEG2000)
check = true;
+ else
+ check = CheckWriteIntegrity(); // verifies length
if (check)
{
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
bool Parsed;
// Utility pixel converter
+
/// \brief Pointer to the PixelReadConverter
PixelReadConvert *PixelReadConverter;
+
/// \brief Pointer to the PixelWriteConverter
PixelWriteConvert *PixelWriteConverter;
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
*/
PixelWriteConvert::~PixelWriteConvert()
{
+ gdcmDebugMacro("PixelWriteConvert::~PixelWriteConvert()" );
if( Compressed )
{
delete[] UserData;
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;
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;