X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmPixelWriteConvert.cxx;h=4cd1fcddbcf970252a744132cb0bcf773916bcf1;hb=76ac46b16fd92d0fb444f786d4946424d9029315;hp=0ba8891688e0d8680a0304bf6c499756fc577ffc;hpb=f58d0f1e0e1680554dcd631817b7f81968fdb950;p=gdcm.git diff --git a/src/gdcmPixelWriteConvert.cxx b/src/gdcmPixelWriteConvert.cxx index 0ba88916..4cd1fcdd 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/29 08:10:14 $ - Version: $Revision: 1.20 $ + Date: $Date: 2008/04/10 12:15:36 $ + 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 @@ -22,6 +22,7 @@ #include "gdcmUtil.h" #include +#include // abs #define WITHOFFSETTABLE 1 @@ -252,7 +253,7 @@ void PixelWriteConvert::SetCompressJPEG2000UserData(uint8_t *data, size_t size, //assert( fragment_size*zsize == size ); gdcmDebugMacro("fragment_size " << fragment_size << " zsize " << zsize << " size " << size); - assert( abs(fragment_size*zsize-size) <=1 ); + assert( abs((long)(fragment_size*zsize-size)) <=1 ); JpegVector JpegFragmentSize; gdcmDebugMacro("Call Encode..BasicOffsetTable " ); @@ -267,7 +268,7 @@ void PixelWriteConvert::SetCompressJPEG2000UserData(uint8_t *data, size_t size, uint8_t *pImageData = data; for(int i=0; itellp(); @@ -328,62 +329,74 @@ void PixelWriteConvert::SetCompressJPEGUserData(uint8_t *data, size_t size, File int xsize = image->GetXSize(); int ysize = image->GetYSize(); int zsize = image->GetZSize(); + int samplesPerPixel = image->GetSamplesPerPixel(); + int bitsAllocated = image->GetBitsAllocated(); + int bitsStored = image->GetBitsStored(); + //std::cout << "X: " << xsize << std::endl; //std::cout << "Y: " << ysize << std::endl; //std::cout << "Sample: " << samplesPerPixel << std::endl; - int bitsallocated = image->GetBitsAllocated(); - unsigned int fragment_size = xsize*ysize*samplesPerPixel * (bitsallocated / 8); + + gdcmDebugMacro( "bitsAllocated " << bitsAllocated << " bitsStored " <tellp(); - if( bitsallocated == 8 ) + if( bitsStored == 8 ) { gdcm_write_JPEG_file8(of, (char*)pImageData,size, - image->GetXSize(), image->GetYSize(), image->GetZSize(), image->GetSamplesPerPixel(), - image->GetBitsAllocated(), 100 ); + xsize, ysize, zsize, samplesPerPixel, + bitsAllocated, 100 ); } - else if (bitsallocated <= 12) + else if (bitsStored <= 12) { - assert( bitsallocated >= 8 ); - gdcm_write_JPEG_file12(of, (char*)pImageData,size, - image->GetXSize(), image->GetYSize(), image->GetZSize(), image->GetSamplesPerPixel(), - image->GetBitsAllocated(), 100); + assert( bitsStored >= 8 ); + gdcm_write_JPEG_file12(of, (char*)pImageData, size, + xsize, ysize, zsize, samplesPerPixel, + bitsAllocated, 100); } - else if (bitsallocated <= 16) + else if (bitsStored <= 16) { - assert( bitsallocated >= 12 ); + assert( bitsStored >= 12 ); gdcm_write_JPEG_file16(of, (char*)pImageData,size, - image->GetXSize(), image->GetYSize(), image->GetZSize(), image->GetSamplesPerPixel(), - image->GetBitsAllocated(), 100); + xsize, ysize, zsize, samplesPerPixel, + bitsAllocated, 100); } - else if (bitsallocated <= 32) // if we are lucky (?), it will compress as a 2 bytes stream + else if (bitsStored <= 32) // if we are lucky (?), it will compress as a 2 bytes stream { // (Actually it doesn't !) // Just to allow ctest not to abort on 32bits per pixel image RTDOSE.dcm - assert( bitsallocated >= 16 ); - gdcmDebugMacro( "Warning : bitsallocated>16 not supported by JPEG !" ); + assert( bitsStored >= 16 ); + gdcmDebugMacro( "Warning : bitsStored>16 not supported by JPEG !" ); gdcm_write_JPEG_file16(of, (char*)pImageData, size, - image->GetXSize(), image->GetYSize(), image->GetZSize(), image->GetSamplesPerPixel(), - image->GetBitsAllocated(), 100); + xsize, ysize, zsize, samplesPerPixel, + bitsAllocated, 100); } else { - gdcmDebugMacro( "Major pb : bitsallocated =" << bitsallocated ); + std::cerr << "Major pb : bitsStored =" << bitsStored << std::endl; abort(); } size_t end = of->tellp();