1 /*=========================================================================
4 Module: $RCSfile: gdcmFileHelper.cxx,v $
6 Date: $Date: 2005/01/21 11:40:55 $
7 Version: $Revision: 1.2 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #include "gdcmFileHelper.h"
20 #include "gdcmGlobal.h"
22 #include "gdcmDocument.h"
23 #include "gdcmDebug.h"
25 #include "gdcmBinEntry.h"
27 #include "gdcmPixelReadConvert.h"
28 #include "gdcmPixelWriteConvert.h"
29 #include "gdcmDocEntryArchive.h"
35 typedef std::pair<TagDocEntryHT::iterator,TagDocEntryHT::iterator> IterHT;
37 //-------------------------------------------------------------------------
38 // Constructor / Destructor
40 * \brief Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3
41 * file (gdcm::File only deals with the ... header)
42 * Opens (in read only and when possible) an existing file and checks
43 * for DICOM compliance. Returns NULL on failure.
44 * It will be up to the user to load the pixels into memory
45 * \note the in-memory representation of all available tags found in
46 * the DICOM header is post-poned to first header information access.
47 * This avoid a double parsing of public part of the header when
48 * one sets an a posteriori shadow dictionary (efficiency can be
49 * seen as a side effect).
51 FileHelper::FileHelper( )
53 FileInternal = new File( );
59 * \brief Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3
60 * file (File only deals with the ... header)
61 * Opens (in read only and when possible) an existing file and checks
62 * for DICOM compliance. Returns NULL on failure.
63 * It will be up to the user to load the pixels into memory
64 * \note the in-memory representation of all available tags found in
65 * the DICOM header is post-poned to first header information access.
66 * This avoid a double parsing of public part of the header when
67 * user sets an a posteriori shadow dictionary (efficiency can be
68 * seen as a side effect).
69 * @param header already built Header
71 FileHelper::FileHelper(File *header)
73 FileInternal = header;
79 * \brief Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3
80 * file (gdcm::File only deals with the ... header)
81 * Opens (in read only and when possible) an existing file and checks
82 * for DICOM compliance. Returns NULL on failure.
83 * It will be up to the user to load the pixels into memory
84 * \note the in-memory representation of all available tags found in
85 * the DICOM header is post-poned to first header information access.
86 * This avoid a double parsing of public part of the header when
87 * one sets an a posteriori shadow dictionary (efficiency can be
88 * seen as a side effect).
89 * @param filename file to be opened for parsing
91 FileHelper::FileHelper(std::string const & filename )
93 FileInternal = new File( filename );
99 * \brief canonical destructor
100 * \note If the header (gdcm::File) was created by the FileHelper constructor,
101 * it is destroyed by the FileHelper
103 FileHelper::~FileHelper()
105 if( PixelReadConverter )
107 delete PixelReadConverter;
109 if( PixelWriteConverter )
111 delete PixelWriteConverter;
125 //-----------------------------------------------------------------------------
127 void FileHelper::Print(std::ostream &os, std::string const &)
129 FileInternal->SetPrintLevel(PrintLevel);
130 FileInternal->Print(os);
132 PixelReadConverter->SetPrintLevel(PrintLevel);
133 PixelReadConverter->Print(os);
136 //-----------------------------------------------------------------------------
139 * \brief Get the size of the image data
140 * If the image can be RGB (with a lut or by default), the size
141 * corresponds to the RGB image
142 * (use GetImageDataRawSize if you want to be sure to get *only*
143 * the size of the pixels)
144 * @return The image size
146 size_t FileHelper::GetImageDataSize()
148 if ( PixelWriteConverter->GetUserData() )
150 return PixelWriteConverter->GetUserDataSize();
153 return PixelReadConverter->GetRGBSize();
157 * \brief Get the size of the image data
158 * If the image could be converted to RGB using a LUT,
159 * this transformation is not taken into account by GetImageDataRawSize
160 * (use GetImageDataSize if you wish)
161 * @return The raw image size
163 size_t FileHelper::GetImageDataRawSize()
165 if ( PixelWriteConverter->GetUserData() )
167 return PixelWriteConverter->GetUserDataSize();
170 return PixelReadConverter->GetRawSize();
174 * \brief - Allocates necessary memory,
175 * - Reads the pixels from disk (uncompress if necessary),
176 * - Transforms YBR pixels, if any, into RGB pixels
177 * - Transforms 3 planes R, G, B, if any, into a single RGB Plane
178 * - Transforms single Grey plane + 3 Palettes into a RGB Plane
179 * - Copies the pixel data (image[s]/volume[s]) to newly allocated zone.
180 * @return Pointer to newly allocated pixel data.
181 * NULL if alloc fails
183 uint8_t *FileHelper::GetImageData()
185 if ( PixelWriteConverter->GetUserData() )
187 return PixelWriteConverter->GetUserData();
192 // If the decompression failed nothing can be done.
196 if ( FileInternal->HasLUT() && PixelReadConverter->BuildRGBImage() )
198 return PixelReadConverter->GetRGB();
202 // When no LUT or LUT conversion fails, return the Raw
203 return PixelReadConverter->GetRaw();
208 * \brief Allocates necessary memory,
209 * Transforms YBR pixels (if any) into RGB pixels
210 * Transforms 3 planes R, G, B (if any) into a single RGB Plane
211 * Copies the pixel data (image[s]/volume[s]) to newly allocated zone.
212 * DOES NOT transform Grey plane + 3 Palettes into a RGB Plane
213 * @return Pointer to newly allocated pixel data.
214 * \ NULL if alloc fails
216 uint8_t *FileHelper::GetImageDataRaw ()
223 * Read the pixels from disk (uncompress if necessary),
224 * Transforms YBR pixels, if any, into RGB pixels
225 * Transforms 3 planes R, G, B, if any, into a single RGB Plane
226 * Transforms single Grey plane + 3 Palettes into a RGB Plane
227 * Copies at most MaxSize bytes of pixel data to caller allocated
229 * \warning This function allows people that want to build a volume
230 * from an image stack *not to* have, first to get the image pixels,
231 * and then move them to the volume area.
232 * It's absolutely useless for any VTK user since vtk chooses
233 * to invert the lines of an image, that is the last line comes first
234 * (for some axis related reasons?). Hence he will have
235 * to load the image line by line, starting from the end.
236 * VTK users have to call GetImageData
238 * @param destination Address (in caller's memory space) at which the
239 * pixel data should be copied
240 * @param maxSize Maximum number of bytes to be copied. When MaxSize
241 * is not sufficient to hold the pixel data the copy is not
242 * executed (i.e. no partial copy).
243 * @return On success, the number of bytes actually copied. Zero on
244 * failure e.g. MaxSize is lower than necessary.
246 size_t FileHelper::GetImageDataIntoVector (void *destination, size_t maxSize)
250 // If the decompression failed nothing can be done.
254 if ( FileInternal->HasLUT() && PixelReadConverter->BuildRGBImage() )
256 if ( PixelReadConverter->GetRGBSize() > maxSize )
258 gdcmVerboseMacro( "Pixel data bigger than caller's expected MaxSize");
262 (void*)PixelReadConverter->GetRGB(),
263 PixelReadConverter->GetRGBSize() );
264 return PixelReadConverter->GetRGBSize();
267 // Either no LUT conversion necessary or LUT conversion failed
268 if ( PixelReadConverter->GetRawSize() > maxSize )
270 gdcmVerboseMacro( "Pixel data bigger than caller's expected MaxSize");
274 (void*)PixelReadConverter->GetRaw(),
275 PixelReadConverter->GetRawSize() );
276 return PixelReadConverter->GetRawSize();
280 * \brief Points the internal pointer to the callers inData
281 * image representation, BUT WITHOUT COPYING THE DATA.
282 * 'image' Pixels are presented as C-like 2D arrays : line per line.
283 * 'volume'Pixels are presented as C-like 3D arrays : plane per plane
284 * \warning Since the pixels are not copied, it is the caller's responsability
285 * not to deallocate it's data before gdcm uses them (e.g. with
286 * the Write() method.
287 * @param inData user supplied pixel area
288 * @param expectedSize total image size, in Bytes
292 void FileHelper::SetImageData(uint8_t *inData, size_t expectedSize)
294 SetUserData(inData,expectedSize);
298 * \brief Set the image datas defined by the user
299 * \warning When writting the file, this datas are get as default datas to write
301 void FileHelper::SetUserData(uint8_t *data, size_t expectedSize)
303 PixelWriteConverter->SetUserData(data,expectedSize);
307 * \brief Get the image datas defined by the user
308 * \warning When writting the file, this datas are get as default data to write
310 uint8_t *FileHelper::GetUserData()
312 return PixelWriteConverter->GetUserData();
316 * \brief Get the image data size defined by the user
317 * \warning When writting the file, this datas are get as default data to write
319 size_t FileHelper::GetUserDataSize()
321 return PixelWriteConverter->GetUserDataSize();
325 * \brief Get the image datas from the file.
326 * If a LUT is found, the data are expanded to be RGB
328 uint8_t *FileHelper::GetRGBData()
330 return PixelReadConverter->GetRGB();
334 * \brief Get the image data size from the file.
335 * If a LUT is found, the data are expanded to be RGB
337 size_t FileHelper::GetRGBDataSize()
339 return PixelReadConverter->GetRGBSize();
343 * \brief Get the image datas from the file.
344 * If a LUT is found, the datas are not expanded !
346 uint8_t *FileHelper::GetRawData()
348 return PixelReadConverter->GetRaw();
352 * \brief Get the image data size from the file.
353 * If a LUT is found, the data are not expanded !
355 size_t FileHelper::GetRawDataSize()
357 return PixelReadConverter->GetRawSize();
361 * \brief Writes on disk A SINGLE Dicom file
362 * NO test is performed on processor "Endiannity".
363 * It's up to the user to call his Reader properly
364 * @param fileName name of the file to be created
365 * (any already existing file is over written)
366 * @return false if write fails
369 bool FileHelper::WriteRawData(std::string const &fileName)
371 std::ofstream fp1(fileName.c_str(), std::ios::out | std::ios::binary );
374 gdcmVerboseMacro( "Fail to open (write) file:" << fileName.c_str());
378 if( PixelWriteConverter->GetUserData() )
380 fp1.write( (char*)PixelWriteConverter->GetUserData(),
381 PixelWriteConverter->GetUserDataSize() );
383 else if ( PixelReadConverter->GetRGB() )
385 fp1.write( (char*)PixelReadConverter->GetRGB(),
386 PixelReadConverter->GetRGBSize());
388 else if ( PixelReadConverter->GetRaw() )
390 fp1.write( (char*)PixelReadConverter->GetRaw(),
391 PixelReadConverter->GetRawSize());
395 gdcmErrorMacro( "Nothing written." );
404 * \brief Writes on disk A SINGLE Dicom file,
405 * using the Implicit Value Representation convention
406 * NO test is performed on processor "Endiannity".
407 * @param fileName name of the file to be created
408 * (any already existing file is overwritten)
409 * @return false if write fails
412 bool FileHelper::WriteDcmImplVR (std::string const &fileName)
414 SetWriteTypeToDcmImplVR();
415 return Write(fileName);
419 * \brief Writes on disk A SINGLE Dicom file,
420 * using the Explicit Value Representation convention
421 * NO test is performed on processor "Endiannity".
422 * @param fileName name of the file to be created
423 * (any already existing file is overwritten)
424 * @return false if write fails
427 bool FileHelper::WriteDcmExplVR (std::string const &fileName)
429 SetWriteTypeToDcmExplVR();
430 return Write(fileName);
434 * \brief Writes on disk A SINGLE Dicom file,
435 * using the ACR-NEMA convention
436 * NO test is performed on processor "Endiannity".
437 * (a l'attention des logiciels cliniques
438 * qui ne prennent en entrée QUE des images ACR ...
439 * \warning if a DICOM_V3 header is supplied,
440 * groups < 0x0008 and shadow groups are ignored
441 * \warning NO TEST is performed on processor "Endiannity".
442 * @param fileName name of the file to be created
443 * (any already existing file is overwritten)
444 * @return false if write fails
447 bool FileHelper::WriteAcr (std::string const &fileName)
450 return Write(fileName);
454 * \brief Writes on disk A SINGLE Dicom file,
455 * @param fileName name of the file to be created
456 * (any already existing file is overwritten)
457 * @return false if write fails
459 bool FileHelper::Write(std::string const &fileName)
464 SetWriteFileTypeToImplicitVR();
467 SetWriteFileTypeToExplicitVR();
471 SetWriteFileTypeToACR();
474 SetWriteFileTypeToExplicitVR();
477 // --------------------------------------------------------------
478 // Special Patch to allow gdcm to re-write ACR-LibIDO formated images
480 // if recognition code tells us we dealt with a LibIDO image
481 // we reproduce on disk the switch between lineNumber and columnNumber
482 // just before writting ...
483 /// \todo the best trick would be *change* the recognition code
484 /// but pb expected if user deals with, e.g. COMPLEX images
485 if( WriteType == ACR_LIBIDO )
491 SetWriteToNoLibido();
493 // ----------------- End of Special Patch ----------------
505 bool check = CheckWriteIntegrity();
508 check = FileInternal->Write(fileName,WriteType);
512 RestoreWriteFileType();
514 // --------------------------------------------------------------
515 // Special Patch to allow gdcm to re-write ACR-LibIDO formated images
517 // ...and we restore the header to be Dicom Compliant again
518 // just after writting
519 RestoreWriteOfLibido();
520 // ----------------- End of Special Patch ----------------
526 * \brief Accesses an existing DocEntry (i.e. a Dicom Element)
527 * through it's (group, element) and modifies it's content with
529 * @param content new value (string) to substitute with
530 * @param group group number of the Dicom Element to modify
531 * @param elem element number of the Dicom Element to modify
533 bool FileHelper::SetEntry(std::string const &content,
534 uint16_t group, uint16_t elem)
536 return FileInternal->SetEntry(content,group,elem);
541 * \brief Accesses an existing DocEntry (i.e. a Dicom Element)
542 * through it's (group, element) and modifies it's content with
544 * @param content new value (void* -> uint8_t*) to substitute with
545 * @param lgth new value length
546 * @param group group number of the Dicom Element to modify
547 * @param elem element number of the Dicom Element to modify
549 bool FileHelper::SetEntry(uint8_t *content, int lgth,
550 uint16_t group, uint16_t elem)
552 return FileInternal->SetEntry(content,lgth,group,elem);
556 * \brief Modifies the value of a given DocEntry (Dicom entry)
557 * when it exists. Create it with the given value when unexistant.
558 * @param content (string) Value to be set
559 * @param group Group number of the Entry
560 * @param elem Element number of the Entry
561 * \return pointer to the modified/created Dicom entry (NULL when creation
564 bool FileHelper::ReplaceOrCreate(std::string const &content,
565 uint16_t group, uint16_t elem)
567 return FileInternal->ReplaceOrCreate(content,group,elem) != NULL;
571 * \brief Modifies the value of a given DocEntry (Dicom entry)
572 * when it exists. Create it with the given value when unexistant.
573 * A copy of the binArea is made to be kept in the Document.
574 * @param binArea (binary) value to be set
575 * @param group Group number of the Entry
576 * @param elem Element number of the Entry
577 * \return pointer to the modified/created Dicom entry (NULL when creation
580 bool FileHelper::ReplaceOrCreate(uint8_t *binArea, int lgth,
581 uint16_t group, uint16_t elem)
583 return FileInternal->ReplaceOrCreate(binArea,lgth,group,elem) != NULL;
587 * \brief Access to the underlying \ref PixelReadConverter RGBA LUT
589 uint8_t* FileHelper::GetLutRGBA()
591 return PixelReadConverter->GetLutRGBA();
594 //-----------------------------------------------------------------------------
598 * \brief Check the write integrity
600 * The tests made are :
601 * - verify the size of the image to write with the possible write
602 * when the user set an image data
603 * @return true if the check successfulls
605 bool FileHelper::CheckWriteIntegrity()
607 if(PixelWriteConverter->GetUserData())
609 int numberBitsAllocated = FileInternal->GetBitsAllocated();
610 if ( numberBitsAllocated == 0 || numberBitsAllocated == 12 )
612 numberBitsAllocated = 16;
615 size_t decSize = FileInternal->GetXSize()
616 * FileInternal->GetYSize()
617 * FileInternal->GetZSize()
618 * ( numberBitsAllocated / 8 )
619 * FileInternal->GetSamplesPerPixel();
620 size_t rgbSize = decSize;
621 if( FileInternal->HasLUT() )
622 rgbSize = decSize * 3;
627 if( decSize!=PixelWriteConverter->GetUserDataSize() )
629 gdcmVerboseMacro( "Data size is incorrect (Raw)" << decSize
630 << " / " << PixelWriteConverter->GetUserDataSize() );
635 if( rgbSize!=PixelWriteConverter->GetUserDataSize() )
637 gdcmVerboseMacro( "Data size is incorrect (RGB)" << decSize
638 << " / " << PixelWriteConverter->GetUserDataSize() );
651 void FileHelper::SetWriteToRaw()
653 if( FileInternal->GetNumberOfScalarComponents() == 3
654 && !FileInternal->HasLUT())
660 ValEntry *photInt = CopyValEntry(0x0028,0x0004);
661 if(FileInternal->HasLUT())
663 photInt->SetValue("PALETTE COLOR ");
667 photInt->SetValue("MONOCHROME1 ");
670 PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(),
671 PixelReadConverter->GetRawSize());
674 CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel());
675 pixel->SetValue(GDCM_BINLOADED);
676 pixel->SetBinArea(PixelWriteConverter->GetData(),false);
677 pixel->SetLength(PixelWriteConverter->GetDataSize());
679 Archive->Push(photInt);
680 Archive->Push(pixel);
687 void FileHelper::SetWriteToRGB()
689 if(FileInternal->GetNumberOfScalarComponents()==3)
691 PixelReadConverter->BuildRGBImage();
693 ValEntry *spp = CopyValEntry(0x0028,0x0002);
696 ValEntry *planConfig = CopyValEntry(0x0028,0x0006);
697 planConfig->SetValue("0 ");
699 ValEntry *photInt = CopyValEntry(0x0028,0x0004);
700 photInt->SetValue("RGB ");
702 if(PixelReadConverter->GetRGB())
704 PixelWriteConverter->SetReadData(PixelReadConverter->GetRGB(),
705 PixelReadConverter->GetRGBSize());
709 PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(),
710 PixelReadConverter->GetRawSize());
714 CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel());
715 pixel->SetValue(GDCM_BINLOADED);
716 pixel->SetBinArea(PixelWriteConverter->GetData(),false);
717 pixel->SetLength(PixelWriteConverter->GetDataSize());
720 Archive->Push(planConfig);
721 Archive->Push(photInt);
722 Archive->Push(pixel);
725 Archive->Push(0x0028,0x1101);
726 Archive->Push(0x0028,0x1102);
727 Archive->Push(0x0028,0x1103);
728 Archive->Push(0x0028,0x1201);
729 Archive->Push(0x0028,0x1202);
730 Archive->Push(0x0028,0x1203);
733 // Thus, we have a RGB image and the bits allocated = 24 and
734 // samples per pixels = 1 (in the read file)
735 if(FileInternal->GetBitsAllocated()==24)
737 ValEntry *bitsAlloc = CopyValEntry(0x0028,0x0100);
738 bitsAlloc->SetValue("8 ");
740 ValEntry *bitsStored = CopyValEntry(0x0028,0x0101);
741 bitsStored->SetValue("8 ");
743 ValEntry *highBit = CopyValEntry(0x0028,0x0102);
744 highBit->SetValue("7 ");
746 Archive->Push(bitsAlloc);
747 Archive->Push(bitsStored);
748 Archive->Push(highBit);
760 void FileHelper::RestoreWrite()
762 Archive->Restore(0x0028,0x0002);
763 Archive->Restore(0x0028,0x0004);
764 Archive->Restore(0x0028,0x0006);
765 Archive->Restore(GetFile()->GetGrPixel(),GetFile()->GetNumPixel());
767 // For old ACR-NEMA (24 bits problem)
768 Archive->Restore(0x0028,0x0100);
769 Archive->Restore(0x0028,0x0101);
770 Archive->Restore(0x0028,0x0102);
773 Archive->Restore(0x0028,0x1101);
774 Archive->Restore(0x0028,0x1102);
775 Archive->Restore(0x0028,0x1103);
776 Archive->Restore(0x0028,0x1201);
777 Archive->Restore(0x0028,0x1202);
778 Archive->Restore(0x0028,0x1203);
784 void FileHelper::SetWriteFileTypeToACR()
786 Archive->Push(0x0002,0x0010);
792 void FileHelper::SetWriteFileTypeToExplicitVR()
794 std::string ts = Util::DicomString(
795 Global::GetTS()->GetSpecialTransferSyntax(TS::ExplicitVRLittleEndian) );
797 ValEntry *tss = CopyValEntry(0x0002,0x0010);
806 void FileHelper::SetWriteFileTypeToImplicitVR()
808 std::string ts = Util::DicomString(
809 Global::GetTS()->GetSpecialTransferSyntax(TS::ImplicitVRLittleEndian) );
811 ValEntry *tss = CopyValEntry(0x0002,0x0010);
821 void FileHelper::RestoreWriteFileType()
823 Archive->Restore(0x0002,0x0010);
826 void FileHelper::SetWriteToLibido()
828 ValEntry *oldRow = dynamic_cast<ValEntry *>
829 (FileInternal->GetDocEntry(0x0028, 0x0010));
830 ValEntry *oldCol = dynamic_cast<ValEntry *>
831 (FileInternal->GetDocEntry(0x0028, 0x0011));
833 if( oldRow && oldCol )
835 std::string rows, columns;
837 ValEntry *newRow=new ValEntry(oldRow->GetDictEntry());
838 ValEntry *newCol=new ValEntry(oldCol->GetDictEntry());
840 newRow->Copy(oldCol);
841 newCol->Copy(oldRow);
843 newRow->SetValue(oldCol->GetValue());
844 newCol->SetValue(oldRow->GetValue());
846 Archive->Push(newRow);
847 Archive->Push(newCol);
850 ValEntry *libidoCode = CopyValEntry(0x0008,0x0010);
851 libidoCode->SetValue("ACRNEMA_LIBIDO_1.1");
852 Archive->Push(libidoCode);
858 void FileHelper::SetWriteToNoLibido()
860 ValEntry *recCode = dynamic_cast<ValEntry *>
861 (FileInternal->GetDocEntry(0x0008,0x0010));
864 if( recCode->GetValue() == "ACRNEMA_LIBIDO_1.1" )
866 ValEntry *libidoCode = CopyValEntry(0x0008,0x0010);
867 libidoCode->SetValue("");
868 Archive->Push(libidoCode);
876 void FileHelper::RestoreWriteOfLibido()
878 Archive->Restore(0x0028,0x0010);
879 Archive->Restore(0x0028,0x0011);
880 Archive->Restore(0x0008,0x0010);
883 ValEntry *FileHelper::CopyValEntry(uint16_t group,uint16_t elem)
885 DocEntry *oldE = FileInternal->GetDocEntry(group, elem);
890 newE = new ValEntry(oldE->GetDictEntry());
895 newE = GetFile()->NewValEntry(group,elem);
902 * \brief Modifies the value of a given Bin Entry (Dicom Element)
903 * when it exists. Create it with the given value when unexistant.
904 * @param content (string) Value to be set
905 * @param group Group number of the Entry
906 * @param elem Element number of the Entry
907 * \return pointer to the modified/created Bin Entry (NULL when creation
910 BinEntry *FileHelper::CopyBinEntry(uint16_t group,uint16_t elem)
912 DocEntry *oldE = FileInternal->GetDocEntry(group, elem);
917 newE = new BinEntry(oldE->GetDictEntry());
922 newE = GetFile()->NewBinEntry(group,elem);
928 //-----------------------------------------------------------------------------
931 * \brief Factorization for various forms of constructors.
933 void FileHelper::Initialize()
935 WriteMode = WMODE_RAW;
936 WriteType = ExplicitVR;
938 PixelReadConverter = new PixelReadConvert;
939 PixelWriteConverter = new PixelWriteConvert;
940 Archive = new DocEntryArchive( FileInternal );
942 if ( FileInternal->IsReadable() )
944 PixelReadConverter->GrabInformationsFromHeader( FileInternal );
951 uint8_t *FileHelper::GetRaw()
953 uint8_t *raw = PixelReadConverter->GetRaw();
956 // The Raw image migth not be loaded yet:
957 std::ifstream *fp = FileInternal->OpenFile();
958 PixelReadConverter->ReadAndDecompressPixelData( fp );
960 FileInternal->CloseFile();
962 raw = PixelReadConverter->GetRaw();
965 gdcmVerboseMacro( "Read/decompress of pixel data apparently went wrong.");
973 //-----------------------------------------------------------------------------
976 //-----------------------------------------------------------------------------
977 } // end namespace gdcm