#include <gdcmPixelWriteConvert.h>
Inheritance diagram for GDCM_NAME_SPACE::PixelWriteConvert:
Public Member Functions | |
virtual void | Print (std::ostream &=std::cout, std::string const &="") |
Printer. | |
void | SetPrintLevel (int level) |
Sets the print level for the Dicom Header Elements. | |
int | GetPrintLevel () |
Gets the print level for the Dicom Entries. | |
Protected Attributes | |
int | PrintLevel |
Amount of printed details for each Dicom Entries : 0 : stands for the least detail level. | |
Private Member Functions | |
PixelWriteConvert () | |
Constructor. | |
virtual | ~PixelWriteConvert () |
Destructor. | |
void | SetReadData (uint8_t *data, size_t size) |
sets Read Data (and size) | |
uint8_t * | GetReadData () |
returns ReadData | |
size_t | GetReadDataSize () |
returns ReadDataSize | |
void | SetUserData (uint8_t *data, size_t size) |
Sets the internal pointer to the caller's inData image representation, WITHOUT COPYING THE DATA.
| |
uint8_t * | GetUserData () |
returns UserData | |
size_t | GetUserDataSize () |
returns UserDataSize | |
uint8_t * | GetData () |
Get Data (UserData or ReadData). | |
size_t | GetDataSize () |
Get Data Size (UserData or ReadData). | |
void | SetCompressJPEG2000UserData (uint8_t *data, size_t size, File *image) |
void | SetCompressJPEGUserData (uint8_t *data, size_t size, File *image) |
Private Attributes | |
uint8_t * | ReadData |
Pixel data represented as RGB after LUT color interpretation. | |
size_t | ReadDataSize |
Size of RGB image. | |
uint8_t * | UserData |
User pixel data. | |
size_t | UserDataSize |
Size of User image. | |
bool | Compressed |
Whether we want to write compressed or not. | |
Friends | |
class | FileHelper |
Definition at line 35 of file gdcmPixelWriteConvert.h.
|
Constructor.
Definition at line 43 of file gdcmPixelWriteConvert.cxx. References Compressed, ReadData, ReadDataSize, UserData, and UserDataSize. 00044 { 00045 ReadData = 0; 00046 ReadDataSize = 0; 00047 00048 UserData = 0; 00049 UserDataSize = 0; 00050 Compressed = false; 00051 }
|
|
Destructor.
Definition at line 56 of file gdcmPixelWriteConvert.cxx. References Compressed, gdcmDebugMacro, and UserData. 00057 { 00058 gdcmDebugMacro("PixelWriteConvert::~PixelWriteConvert()" ); 00059 if( Compressed ) 00060 { 00061 delete[] UserData; 00062 } 00063 }
|
|
Get Data (UserData or ReadData).
Definition at line 100 of file gdcmPixelWriteConvert.cxx. References ReadData, and UserData. 00101 { 00102 if ( UserData ) 00103 { 00104 return UserData; 00105 } 00106 else 00107 { 00108 return ReadData; 00109 } 00110 }
|
|
Get Data Size (UserData or ReadData).
Definition at line 116 of file gdcmPixelWriteConvert.cxx. References ReadDataSize, UserData, and UserDataSize. 00117 { 00118 if ( UserData ) 00119 { 00120 return UserDataSize; 00121 } 00122 else 00123 { 00124 return ReadDataSize; 00125 } 00126 }
|
|
Gets the print level for the Dicom Entries.
Definition at line 50 of file gdcmBase.h. 00050 { return PrintLevel; }
|
|
returns ReadData
Definition at line 46 of file gdcmPixelWriteConvert.h. 00046 { return ReadData; }
|
|
returns ReadDataSize
Definition at line 48 of file gdcmPixelWriteConvert.h. 00048 { return ReadDataSize; }
|
|
returns UserData
Definition at line 53 of file gdcmPixelWriteConvert.h. Referenced by GDCM_NAME_SPACE::FileHelper::CheckWriteIntegrity(), GDCM_NAME_SPACE::FileHelper::GetImageData(), GDCM_NAME_SPACE::FileHelper::GetImageDataRawSize(), GDCM_NAME_SPACE::FileHelper::GetImageDataSize(), GDCM_NAME_SPACE::FileHelper::GetUserData(), and GDCM_NAME_SPACE::FileHelper::WriteRawData(). 00053 { return UserData; }
|
|
returns UserDataSize
Definition at line 55 of file gdcmPixelWriteConvert.h. Referenced by GDCM_NAME_SPACE::FileHelper::CheckWriteIntegrity(), GDCM_NAME_SPACE::FileHelper::GetImageDataRawSize(), GDCM_NAME_SPACE::FileHelper::GetImageDataSize(), GDCM_NAME_SPACE::FileHelper::GetUserDataSize(), and GDCM_NAME_SPACE::FileHelper::WriteRawData(). 00055 { return UserDataSize; }
|
|
|
Definition at line 236 of file gdcmPixelWriteConvert.cxx. References Compressed, GDCM_NAME_SPACE::EncodeWithBasicOffsetTable(), GDCM_NAME_SPACE::EncodeWithoutBasicOffsetTable(), GDCM_NAME_SPACE::gdcm_write_JPEG2000_file(), GDCM_NAME_SPACE::File::GetBitsAllocated(), GDCM_NAME_SPACE::File::GetSamplesPerPixel(), GDCM_NAME_SPACE::File::GetXSize(), GDCM_NAME_SPACE::File::GetYSize(), GDCM_NAME_SPACE::File::GetZSize(), GDCM_NAME_SPACE::File::IsSignedPixelData(), and GDCM_NAME_SPACE::WriteDICOMItems(). Referenced by GDCM_NAME_SPACE::FileHelper::SetUserData(). 00237 { 00238 Compressed = true; 00239 //char * userData = reinterpret_cast<char*>(UserData); 00240 00241 std::ostringstream *of = new std::ostringstream(); 00242 int xsize = image->GetXSize(); 00243 int ysize = image->GetYSize(); 00244 int zsize = image->GetZSize(); 00245 int samplesPerPixel = image->GetSamplesPerPixel(); 00246 //std::cout << "X: " << xsize << std::endl; 00247 //std::cout << "Y: " << ysize << std::endl; 00248 //std::cout << "Sample: " << samplesPerPixel << std::endl; 00249 int bitsallocated = image->GetBitsAllocated(); 00250 int sign = image->IsSignedPixelData(); 00251 unsigned int fragment_size = xsize*ysize*samplesPerPixel * (bitsallocated / 8); 00252 assert( fragment_size*zsize == size ); 00253 00254 JpegVector JpegFragmentSize; 00255 #if WITHOFFSETTABLE 00256 size_t bots; //basic offset table start 00257 EncodeWithBasicOffsetTable(of, zsize, bots); 00258 #else 00259 EncodeWithoutBasicOffsetTable(of, 1); 00260 #endif 00261 uint8_t *pImageData = data; 00262 for(int i=0; i<zsize;i++) 00263 { 00264 WriteDICOMItems(of, JpegFragmentSize); 00265 size_t beg = of->tellp(); 00266 gdcm_write_JPEG2000_file(of, (char*)pImageData,size, 00267 image->GetXSize(), image->GetYSize(), image->GetZSize(), image->GetSamplesPerPixel(), 00268 image->GetBitsAllocated(), sign, 100); 00269 //userData, UserDataSize); 00270 // CreateOneFrame(of, pImageData, fragment_size, xsize, ysize, zsize, 00271 // samplesPerPixel, quality, JpegFragmentSize); 00272 //assert( !(fragment_size % 2) ); 00273 // Update the JpegVector with offset 00274 size_t end = of->tellp(); 00275 //static int i = 0; 00276 JpegPair &jp = JpegFragmentSize[i]; 00277 jp.second = (uint32_t)(end-beg); 00278 if( ((end-beg) % 2) ) 00279 { 00280 of->put( '\0' ); 00281 jp.second += 1; 00282 } 00283 assert( !(jp.second % 2) ); 00284 //std::cerr << "DIFF: " << i <<" -> " << jp.second << std::endl; 00285 //++i; 00286 pImageData += fragment_size; 00287 } 00288 CloseJpeg(of, JpegFragmentSize); 00289 #if WITHOFFSETTABLE 00290 UpdateBasicOffsetTable(of, JpegFragmentSize, bots); 00291 #endif 00292 00293 00294 size_t of_size = of->str().size(); 00295 UserData = new uint8_t[of_size]; 00296 memcpy(UserData, of->str().c_str(), of_size); 00297 UserDataSize = of_size; 00298 delete of; 00299 }
|
|
Definition at line 311 of file gdcmPixelWriteConvert.cxx. References Compressed, GDCM_NAME_SPACE::EncodeWithBasicOffsetTable(), GDCM_NAME_SPACE::EncodeWithoutBasicOffsetTable(), GDCM_NAME_SPACE::gdcm_write_JPEG_file12(), GDCM_NAME_SPACE::gdcm_write_JPEG_file16(), GDCM_NAME_SPACE::gdcm_write_JPEG_file8(), GDCM_NAME_SPACE::File::GetBitsAllocated(), GDCM_NAME_SPACE::File::GetSamplesPerPixel(), GDCM_NAME_SPACE::File::GetXSize(), GDCM_NAME_SPACE::File::GetYSize(), GDCM_NAME_SPACE::File::GetZSize(), and GDCM_NAME_SPACE::WriteDICOMItems(). Referenced by GDCM_NAME_SPACE::FileHelper::SetUserData(). 00312 { 00313 (void)data; 00314 (void)size; 00315 (void)image; 00316 Compressed = true; 00317 //char * userData = reinterpret_cast<char*>(UserData); 00318 00319 std::ostringstream *of = new std::ostringstream(); 00320 int xsize = image->GetXSize(); 00321 int ysize = image->GetYSize(); 00322 int zsize = image->GetZSize(); 00323 int samplesPerPixel = image->GetSamplesPerPixel(); 00324 //std::cout << "X: " << xsize << std::endl; 00325 //std::cout << "Y: " << ysize << std::endl; 00326 //std::cout << "Sample: " << samplesPerPixel << std::endl; 00327 int bitsallocated = image->GetBitsAllocated(); 00328 unsigned int fragment_size = xsize*ysize*samplesPerPixel * (bitsallocated / 8); 00329 assert( fragment_size*zsize == size ); 00330 00331 JpegVector JpegFragmentSize; 00332 #if WITHOFFSETTABLE 00333 size_t bots; //basic offset table start 00334 EncodeWithBasicOffsetTable(of, zsize, bots); 00335 #else 00336 EncodeWithoutBasicOffsetTable(of, 1); 00337 #endif 00338 uint8_t *pImageData = data; 00339 for(int i=0; i<zsize;i++) 00340 { 00341 WriteDICOMItems(of, JpegFragmentSize); 00342 size_t beg = of->tellp(); 00343 if( bitsallocated == 8 ) 00344 { 00345 gdcm_write_JPEG_file8(of, (char*)pImageData,size, 00346 image->GetXSize(), image->GetYSize(), image->GetZSize(), image->GetSamplesPerPixel(), 00347 image->GetBitsAllocated(), 100 ); 00348 } 00349 else if (bitsallocated <= 12) 00350 { 00351 assert( bitsallocated >= 8 ); 00352 gdcm_write_JPEG_file12(of, (char*)pImageData,size, 00353 image->GetXSize(), image->GetYSize(), image->GetZSize(), image->GetSamplesPerPixel(), 00354 image->GetBitsAllocated(), 100); 00355 } 00356 else if (bitsallocated <= 16) 00357 { 00358 assert( bitsallocated >= 12 ); 00359 gdcm_write_JPEG_file16(of, (char*)pImageData,size, 00360 image->GetXSize(), image->GetYSize(), image->GetZSize(), image->GetSamplesPerPixel(), 00361 image->GetBitsAllocated(), 100); 00362 } 00363 else 00364 { 00365 abort(); 00366 } 00367 size_t end = of->tellp(); 00368 //static int i = 0; 00369 JpegPair &jp = JpegFragmentSize[i]; 00370 jp.second = (uint32_t)(end-beg); 00371 if( ((end-beg) % 2) ) 00372 { 00373 of->put( '\0' ); 00374 jp.second += 1; 00375 } 00376 assert( !(jp.second % 2) ); 00377 //std::cerr << "DIFF: " << i <<" -> " << jp.second << std::endl; 00378 //++i; 00379 00380 //JpegPair &jp = v[0]; 00381 //jp.second = 15328; 00382 00383 00384 //userData, UserDataSize); 00385 // CreateOneFrame(of, pImageData, fragment_size, xsize, ysize, zsize, 00386 // samplesPerPixel, quality, JpegFragmentSize); 00387 //assert( !(fragment_size % 2) ); 00388 pImageData += fragment_size; 00389 } 00390 CloseJpeg(of, JpegFragmentSize); 00391 #if WITHOFFSETTABLE 00392 UpdateBasicOffsetTable(of, JpegFragmentSize, bots); 00393 #endif 00394 00395 00396 size_t of_size = of->str().size(); 00397 UserData = new uint8_t[of_size]; 00398 memcpy(UserData, of->str().c_str(), of_size); 00399 UserDataSize = of_size; 00400 delete of; 00401 }
|
|
Sets the print level for the Dicom Header Elements.
Definition at line 47 of file gdcmBase.h. Referenced by GDCM_NAME_SPACE::FileHelper::Print(), and GDCM_NAME_SPACE::DicomDir::Print(). 00047 { PrintLevel = level; }
|
|
sets Read Data (and size)
Definition at line 71 of file gdcmPixelWriteConvert.cxx. References ReadData, and ReadDataSize. Referenced by GDCM_NAME_SPACE::FileHelper::SetWriteToRGB(). 00072 { 00073 ReadData = data; 00074 ReadDataSize = size; 00075 }
|
|
Sets the internal pointer to the caller's inData image representation, WITHOUT COPYING THE DATA.
Definition at line 89 of file gdcmPixelWriteConvert.cxx. References UserData, and UserDataSize. Referenced by GDCM_NAME_SPACE::FileHelper::SetImageData(), and GDCM_NAME_SPACE::FileHelper::SetUserData(). 00090 { 00091 UserData = data; 00092 UserDataSize = size; 00093 }
|
|
Definition at line 37 of file gdcmPixelWriteConvert.h. |
|
Whether we want to write compressed or not.
Definition at line 76 of file gdcmPixelWriteConvert.h. Referenced by PixelWriteConvert(), SetCompressJPEG2000UserData(), SetCompressJPEGUserData(), and ~PixelWriteConvert(). |
|
Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.
Definition at line 55 of file gdcmBase.h. Referenced by GDCM_NAME_SPACE::SeqEntry::Print(), GDCM_NAME_SPACE::FileHelper::Print(), GDCM_NAME_SPACE::ElementSet::Print(), GDCM_NAME_SPACE::DocEntry::Print(), GDCM_NAME_SPACE::DictEntry::Print(), GDCM_NAME_SPACE::DicomDirStudy::Print(), GDCM_NAME_SPACE::DicomDirSerie::Print(), GDCM_NAME_SPACE::DicomDirPatient::Print(), GDCM_NAME_SPACE::DicomDirMeta::Print(), GDCM_NAME_SPACE::DicomDir::Print(), and GDCM_NAME_SPACE::DataEntry::Print(). |
|
Pixel data represented as RGB after LUT color interpretation.
Definition at line 66 of file gdcmPixelWriteConvert.h. Referenced by GetData(), PixelWriteConvert(), and SetReadData(). |
|
Size of RGB image.
Definition at line 68 of file gdcmPixelWriteConvert.h. Referenced by GetDataSize(), PixelWriteConvert(), and SetReadData(). |
|
User pixel data.
Definition at line 71 of file gdcmPixelWriteConvert.h. Referenced by GetData(), GetDataSize(), PixelWriteConvert(), SetUserData(), and ~PixelWriteConvert(). |
|
Size of User image.
Definition at line 73 of file gdcmPixelWriteConvert.h. Referenced by GetDataSize(), PixelWriteConvert(), and SetUserData(). |