1 /*=========================================================================
4 Module: $RCSfile: gdcmFileHelper.cxx,v $
6 Date: $Date: 2005/01/20 16:22:52 $
7 Version: $Revision: 1.1 $
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"
26 #include "gdcmHeader.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 (Header 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 * (see GetImageData, GetImageDataRaw)
46 * \note the in-memory representation of all available tags found in
47 * the DICOM header is post-poned to first header information access.
48 * This avoid a double parsing of public part of the header when
49 * one sets an a posteriori shadow dictionary (efficiency can be
50 * seen as a side effect).
52 FileHelper::FileHelper( )
54 HeaderInternal = new Header( );
60 * \brief Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3
61 * file (Header only deals with the ... header)
62 * Opens (in read only and when possible) an existing file and checks
63 * for DICOM compliance. Returns NULL on failure.
64 * It will be up to the user to load the pixels into memory
65 * (see GetImageData, GetImageDataRaw)
66 * \note the in-memory representation of all available tags found in
67 * the DICOM header is post-poned to first header information access.
68 * This avoid a double parsing of public part of the header when
69 * user sets an a posteriori shadow dictionary (efficiency can be
70 * seen as a side effect).
71 * @param header already built Header
73 FileHelper::FileHelper(Header *header)
75 HeaderInternal = header;
81 * \brief Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3
82 * file (Header only deals with the ... header)
83 * Opens (in read only and when possible) an existing file and checks
84 * for DICOM compliance. Returns NULL on failure.
85 * It will be up to the user to load the pixels into memory
86 * (see GetImageData, GetImageDataRaw)
87 * \note the in-memory representation of all available tags found in
88 * the DICOM header is post-poned to first header information access.
89 * This avoid a double parsing of public part of the header when
90 * one sets an a posteriori shadow dictionary (efficiency can be
91 * seen as a side effect).
92 * @param filename file to be opened for parsing
94 FileHelper::FileHelper(std::string const & filename )
96 HeaderInternal = new Header( filename );
102 * \brief canonical destructor
103 * \note If the header (gdcm::File) was created by the FileHelper constructor,
104 * it is destroyed by the FileHelper
106 FileHelper::~FileHelper()
108 if( PixelReadConverter )
110 delete PixelReadConverter;
112 if( PixelWriteConverter )
114 delete PixelWriteConverter;
123 delete HeaderInternal;
128 //-----------------------------------------------------------------------------
130 void FileHelper::Print(std::ostream &os, std::string const &)
132 HeaderInternal->SetPrintLevel(PrintLevel);
133 HeaderInternal->Print(os);
135 PixelReadConverter->SetPrintLevel(PrintLevel);
136 PixelReadConverter->Print(os);
139 //-----------------------------------------------------------------------------
142 * \brief Get the size of the image data
143 * If the image can be RGB (with a lut or by default), the size
144 * corresponds to the RGB image
145 * (use GetImageDataRawSize if you want to be sure to get *only*
146 * the size of the pixels)
147 * @return The image size
149 size_t FileHelper::GetImageDataSize()
151 if ( PixelWriteConverter->GetUserData() )
153 return PixelWriteConverter->GetUserDataSize();
156 return PixelReadConverter->GetRGBSize();
160 * \brief Get the size of the image data
161 * If the image could be converted to RGB using a LUT,
162 * this transformation is not taken into account by GetImageDataRawSize
163 * (use GetImageDataSize if you wish)
164 * @return The raw image size
166 size_t FileHelper::GetImageDataRawSize()
168 if ( PixelWriteConverter->GetUserData() )
170 return PixelWriteConverter->GetUserDataSize();
173 return PixelReadConverter->GetRawSize();
177 * \brief - Allocates necessary memory,
178 * - Reads the pixels from disk (uncompress if necessary),
179 * - Transforms YBR pixels, if any, into RGB pixels
180 * - Transforms 3 planes R, G, B, if any, into a single RGB Plane
181 * - Transforms single Grey plane + 3 Palettes into a RGB Plane
182 * - Copies the pixel data (image[s]/volume[s]) to newly allocated zone.
183 * @return Pointer to newly allocated pixel data.
184 * NULL if alloc fails
186 uint8_t *FileHelper::GetImageData()
188 if ( PixelWriteConverter->GetUserData() )
190 return PixelWriteConverter->GetUserData();
195 // If the decompression failed nothing can be done.
199 if ( HeaderInternal->HasLUT() && PixelReadConverter->BuildRGBImage() )
201 return PixelReadConverter->GetRGB();
205 // When no LUT or LUT conversion fails, return the Raw
206 return PixelReadConverter->GetRaw();
211 * \brief Allocates necessary memory,
212 * Transforms YBR pixels (if any) into RGB pixels
213 * Transforms 3 planes R, G, B (if any) into a single RGB Plane
214 * Copies the pixel data (image[s]/volume[s]) to newly allocated zone.
215 * DOES NOT transform Grey plane + 3 Palettes into a RGB Plane
216 * @return Pointer to newly allocated pixel data.
217 * \ NULL if alloc fails
219 uint8_t *FileHelper::GetImageDataRaw ()
226 * Read the pixels from disk (uncompress if necessary),
227 * Transforms YBR pixels, if any, into RGB pixels
228 * Transforms 3 planes R, G, B, if any, into a single RGB Plane
229 * Transforms single Grey plane + 3 Palettes into a RGB Plane
230 * Copies at most MaxSize bytes of pixel data to caller allocated
232 * \warning This function allows people that want to build a volume
233 * from an image stack *not to* have, first to get the image pixels,
234 * and then move them to the volume area.
235 * It's absolutely useless for any VTK user since vtk chooses
236 * to invert the lines of an image, that is the last line comes first
237 * (for some axis related reasons?). Hence he will have
238 * to load the image line by line, starting from the end.
239 * VTK users have to call GetImageData
241 * @param destination Address (in caller's memory space) at which the
242 * pixel data should be copied
243 * @param maxSize Maximum number of bytes to be copied. When MaxSize
244 * is not sufficient to hold the pixel data the copy is not
245 * executed (i.e. no partial copy).
246 * @return On success, the number of bytes actually copied. Zero on
247 * failure e.g. MaxSize is lower than necessary.
249 size_t FileHelper::GetImageDataIntoVector (void *destination, size_t maxSize)
253 // If the decompression failed nothing can be done.
257 if ( HeaderInternal->HasLUT() && PixelReadConverter->BuildRGBImage() )
259 if ( PixelReadConverter->GetRGBSize() > maxSize )
261 gdcmVerboseMacro( "Pixel data bigger than caller's expected MaxSize");
265 (void*)PixelReadConverter->GetRGB(),
266 PixelReadConverter->GetRGBSize() );
267 return PixelReadConverter->GetRGBSize();
270 // Either no LUT conversion necessary or LUT conversion failed
271 if ( PixelReadConverter->GetRawSize() > maxSize )
273 gdcmVerboseMacro( "Pixel data bigger than caller's expected MaxSize");
277 (void*)PixelReadConverter->GetRaw(),
278 PixelReadConverter->GetRawSize() );
279 return PixelReadConverter->GetRawSize();
283 * \brief Points the internal pointer to the callers inData
284 * image representation, BUT WITHOUT COPYING THE DATA.
285 * 'image' Pixels are presented as C-like 2D arrays : line per line.
286 * 'volume'Pixels are presented as C-like 3D arrays : plane per plane
287 * \warning Since the pixels are not copied, it is the caller's responsability
288 * not to deallocate it's data before gdcm uses them (e.g. with
289 * the Write() method.
290 * @param inData user supplied pixel area
291 * @param expectedSize total image size, in Bytes
295 void FileHelper::SetImageData(uint8_t *inData, size_t expectedSize)
297 SetUserData(inData,expectedSize);
301 * \brief Set the image datas defined by the user
302 * \warning When writting the file, this datas are get as default datas to write
304 void FileHelper::SetUserData(uint8_t *data, size_t expectedSize)
306 PixelWriteConverter->SetUserData(data,expectedSize);
310 * \brief Get the image datas defined by the user
311 * \warning When writting the file, this datas are get as default data to write
313 uint8_t *FileHelper::GetUserData()
315 return PixelWriteConverter->GetUserData();
319 * \brief Get the image data size defined by the user
320 * \warning When writting the file, this datas are get as default data to write
322 size_t FileHelper::GetUserDataSize()
324 return PixelWriteConverter->GetUserDataSize();
328 * \brief Get the image datas from the file.
329 * If a LUT is found, the data are expanded to be RGB
331 uint8_t *FileHelper::GetRGBData()
333 return PixelReadConverter->GetRGB();
337 * \brief Get the image data size from the file.
338 * If a LUT is found, the data are expanded to be RGB
340 size_t FileHelper::GetRGBDataSize()
342 return PixelReadConverter->GetRGBSize();
346 * \brief Get the image datas from the file.
347 * If a LUT is found, the datas are not expanded !
349 uint8_t *FileHelper::GetRawData()
351 return PixelReadConverter->GetRaw();
355 * \brief Get the image data size from the file.
356 * If a LUT is found, the data are not expanded !
358 size_t FileHelper::GetRawDataSize()
360 return PixelReadConverter->GetRawSize();
364 * \brief Writes on disk A SINGLE Dicom file
365 * NO test is performed on processor "Endiannity".
366 * It's up to the user to call his Reader properly
367 * @param fileName name of the file to be created
368 * (any already existing file is over written)
369 * @return false if write fails
372 bool FileHelper::WriteRawData(std::string const &fileName)
374 std::ofstream fp1(fileName.c_str(), std::ios::out | std::ios::binary );
377 gdcmVerboseMacro( "Fail to open (write) file:" << fileName.c_str());
381 if( PixelWriteConverter->GetUserData() )
383 fp1.write( (char*)PixelWriteConverter->GetUserData(),
384 PixelWriteConverter->GetUserDataSize() );
386 else if ( PixelReadConverter->GetRGB() )
388 fp1.write( (char*)PixelReadConverter->GetRGB(),
389 PixelReadConverter->GetRGBSize());
391 else if ( PixelReadConverter->GetRaw() )
393 fp1.write( (char*)PixelReadConverter->GetRaw(),
394 PixelReadConverter->GetRawSize());
398 gdcmErrorMacro( "Nothing written." );
407 * \brief Writes on disk A SINGLE Dicom file,
408 * using the Implicit Value Representation convention
409 * NO test is performed on processor "Endiannity".
410 * @param fileName name of the file to be created
411 * (any already existing file is overwritten)
412 * @return false if write fails
415 bool FileHelper::WriteDcmImplVR (std::string const &fileName)
417 SetWriteTypeToDcmImplVR();
418 return Write(fileName);
422 * \brief Writes on disk A SINGLE Dicom file,
423 * using the Explicit Value Representation convention
424 * NO test is performed on processor "Endiannity".
425 * @param fileName name of the file to be created
426 * (any already existing file is overwritten)
427 * @return false if write fails
430 bool FileHelper::WriteDcmExplVR (std::string const &fileName)
432 SetWriteTypeToDcmExplVR();
433 return Write(fileName);
437 * \brief Writes on disk A SINGLE Dicom file,
438 * using the ACR-NEMA convention
439 * NO test is performed on processor "Endiannity".
440 * (a l'attention des logiciels cliniques
441 * qui ne prennent en entrée QUE des images ACR ...
442 * \warning if a DICOM_V3 header is supplied,
443 * groups < 0x0008 and shadow groups are ignored
444 * \warning NO TEST is performed on processor "Endiannity".
445 * @param fileName name of the file to be created
446 * (any already existing file is overwritten)
447 * @return false if write fails
450 bool FileHelper::WriteAcr (std::string const &fileName)
453 return Write(fileName);
457 * \brief Writes on disk A SINGLE Dicom file,
458 * @param fileName name of the file to be created
459 * (any already existing file is overwritten)
460 * @return false if write fails
462 bool FileHelper::Write(std::string const &fileName)
467 SetWriteFileTypeToImplicitVR();
470 SetWriteFileTypeToExplicitVR();
474 SetWriteFileTypeToACR();
477 SetWriteFileTypeToExplicitVR();
480 // --------------------------------------------------------------
481 // Special Patch to allow gdcm to re-write ACR-LibIDO formated images
483 // if recognition code tells us we dealt with a LibIDO image
484 // we reproduce on disk the switch between lineNumber and columnNumber
485 // just before writting ...
486 /// \todo the best trick would be *change* the recognition code
487 /// but pb expected if user deals with, e.g. COMPLEX images
488 if( WriteType == ACR_LIBIDO )
494 SetWriteToNoLibido();
496 // ----------------- End of Special Patch ----------------
508 bool check = CheckWriteIntegrity();
511 check = HeaderInternal->Write(fileName,WriteType);
515 RestoreWriteFileType();
517 // --------------------------------------------------------------
518 // Special Patch to allow gdcm to re-write ACR-LibIDO formated images
520 // ...and we restore the Header to be Dicom Compliant again
521 // just after writting
522 RestoreWriteOfLibido();
523 // ----------------- End of Special Patch ----------------
529 * \brief Accesses an existing DocEntry (i.e. a Dicom Element)
530 * through it's (group, element) and modifies it's content with
532 * @param content new value (string) to substitute with
533 * @param group group number of the Dicom Element to modify
534 * @param elem element number of the Dicom Element to modify
536 bool FileHelper::SetEntry(std::string const &content,
537 uint16_t group, uint16_t elem)
539 return HeaderInternal->SetEntry(content,group,elem);
544 * \brief Accesses an existing DocEntry (i.e. a Dicom Element)
545 * through it's (group, element) and modifies it's content with
547 * @param content new value (void* -> uint8_t*) to substitute with
548 * @param lgth new value length
549 * @param group group number of the Dicom Element to modify
550 * @param elem element number of the Dicom Element to modify
552 bool FileHelper::SetEntry(uint8_t *content, int lgth,
553 uint16_t group, uint16_t elem)
555 return HeaderInternal->SetEntry(content,lgth,group,elem);
559 * \brief Modifies the value of a given Doc Entry (Dicom Element)
560 * when it exists. Create it with the given value when unexistant.
561 * @param content (string) Value to be set
562 * @param group Group number of the Entry
563 * @param elem Element number of the Entry
564 * \return pointer to the modified/created Header Entry (NULL when creation
567 bool FileHelper::ReplaceOrCreate(std::string const &content,
568 uint16_t group, uint16_t elem)
570 return HeaderInternal->ReplaceOrCreate(content,group,elem) != NULL;
574 * \brief Modifies the value of a given Header Entry (Dicom Element)
575 * when it exists. Create it with the given value when unexistant.
576 * A copy of the binArea is made to be kept in the Document.
577 * @param binArea (binary) value to be set
578 * @param group Group number of the Entry
579 * @param elem Element number of the Entry
580 * \return pointer to the modified/created Header Entry (NULL when creation
583 bool FileHelper::ReplaceOrCreate(uint8_t *binArea, int lgth,
584 uint16_t group, uint16_t elem)
586 return HeaderInternal->ReplaceOrCreate(binArea,lgth,group,elem) != NULL;
590 * \brief Access to the underlying \ref PixelReadConverter RGBA LUT
592 uint8_t* FileHelper::GetLutRGBA()
594 return PixelReadConverter->GetLutRGBA();
597 //-----------------------------------------------------------------------------
601 * \brief Check the write integrity
603 * The tests made are :
604 * - verify the size of the image to write with the possible write
605 * when the user set an image data
606 * @return true if the check successfulls
608 bool FileHelper::CheckWriteIntegrity()
610 if(PixelWriteConverter->GetUserData())
612 int numberBitsAllocated = HeaderInternal->GetBitsAllocated();
613 if ( numberBitsAllocated == 0 || numberBitsAllocated == 12 )
615 numberBitsAllocated = 16;
618 size_t decSize = HeaderInternal->GetXSize()
619 * HeaderInternal->GetYSize()
620 * HeaderInternal->GetZSize()
621 * ( numberBitsAllocated / 8 )
622 * HeaderInternal->GetSamplesPerPixel();
623 size_t rgbSize = decSize;
624 if( HeaderInternal->HasLUT() )
625 rgbSize = decSize * 3;
630 if( decSize!=PixelWriteConverter->GetUserDataSize() )
632 gdcmVerboseMacro( "Data size is incorrect (Raw)" << decSize
633 << " / " << PixelWriteConverter->GetUserDataSize() );
638 if( rgbSize!=PixelWriteConverter->GetUserDataSize() )
640 gdcmVerboseMacro( "Data size is incorrect (RGB)" << decSize
641 << " / " << PixelWriteConverter->GetUserDataSize() );
654 void FileHelper::SetWriteToRaw()
656 if( HeaderInternal->GetNumberOfScalarComponents() == 3
657 && !HeaderInternal->HasLUT())
663 ValEntry *photInt = CopyValEntry(0x0028,0x0004);
664 if(HeaderInternal->HasLUT())
666 photInt->SetValue("PALETTE COLOR ");
670 photInt->SetValue("MONOCHROME1 ");
673 PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(),
674 PixelReadConverter->GetRawSize());
677 CopyBinEntry(GetHeader()->GetGrPixel(),GetHeader()->GetNumPixel());
678 pixel->SetValue(GDCM_BINLOADED);
679 pixel->SetBinArea(PixelWriteConverter->GetData(),false);
680 pixel->SetLength(PixelWriteConverter->GetDataSize());
682 Archive->Push(photInt);
683 Archive->Push(pixel);
691 void FileHelper::SetWriteToRGB()
693 if(HeaderInternal->GetNumberOfScalarComponents()==3)
695 PixelReadConverter->BuildRGBImage();
697 ValEntry *spp = CopyValEntry(0x0028,0x0002);
700 ValEntry *planConfig = CopyValEntry(0x0028,0x0006);
701 planConfig->SetValue("0 ");
703 ValEntry *photInt = CopyValEntry(0x0028,0x0004);
704 photInt->SetValue("RGB ");
706 if(PixelReadConverter->GetRGB())
708 PixelWriteConverter->SetReadData(PixelReadConverter->GetRGB(),
709 PixelReadConverter->GetRGBSize());
713 PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(),
714 PixelReadConverter->GetRawSize());
718 CopyBinEntry(GetHeader()->GetGrPixel(),GetHeader()->GetNumPixel());
719 pixel->SetValue(GDCM_BINLOADED);
720 pixel->SetBinArea(PixelWriteConverter->GetData(),false);
721 pixel->SetLength(PixelWriteConverter->GetDataSize());
724 Archive->Push(planConfig);
725 Archive->Push(photInt);
726 Archive->Push(pixel);
729 Archive->Push(0x0028,0x1101);
730 Archive->Push(0x0028,0x1102);
731 Archive->Push(0x0028,0x1103);
732 Archive->Push(0x0028,0x1201);
733 Archive->Push(0x0028,0x1202);
734 Archive->Push(0x0028,0x1203);
737 // Thus, we have a RGB image and the bits allocated = 24 and
738 // samples per pixels = 1 (in the read file)
739 if(HeaderInternal->GetBitsAllocated()==24)
741 ValEntry *bitsAlloc = CopyValEntry(0x0028,0x0100);
742 bitsAlloc->SetValue("8 ");
744 ValEntry *bitsStored = CopyValEntry(0x0028,0x0101);
745 bitsStored->SetValue("8 ");
747 ValEntry *highBit = CopyValEntry(0x0028,0x0102);
748 highBit->SetValue("7 ");
750 Archive->Push(bitsAlloc);
751 Archive->Push(bitsStored);
752 Archive->Push(highBit);
764 void FileHelper::RestoreWrite()
766 Archive->Restore(0x0028,0x0002);
767 Archive->Restore(0x0028,0x0004);
768 Archive->Restore(0x0028,0x0006);
769 Archive->Restore(GetHeader()->GetGrPixel(),GetHeader()->GetNumPixel());
771 // For old ACR-NEMA (24 bits problem)
772 Archive->Restore(0x0028,0x0100);
773 Archive->Restore(0x0028,0x0101);
774 Archive->Restore(0x0028,0x0102);
777 Archive->Restore(0x0028,0x1101);
778 Archive->Restore(0x0028,0x1102);
779 Archive->Restore(0x0028,0x1103);
780 Archive->Restore(0x0028,0x1201);
781 Archive->Restore(0x0028,0x1202);
782 Archive->Restore(0x0028,0x1203);
788 void FileHelper::SetWriteFileTypeToACR()
790 Archive->Push(0x0002,0x0010);
796 void FileHelper::SetWriteFileTypeToExplicitVR()
798 std::string ts = Util::DicomString(
799 Global::GetTS()->GetSpecialTransferSyntax(TS::ExplicitVRLittleEndian) );
801 ValEntry *tss = CopyValEntry(0x0002,0x0010);
810 void FileHelper::SetWriteFileTypeToImplicitVR()
812 std::string ts = Util::DicomString(
813 Global::GetTS()->GetSpecialTransferSyntax(TS::ImplicitVRLittleEndian) );
815 ValEntry *tss = CopyValEntry(0x0002,0x0010);
825 void FileHelper::RestoreWriteFileType()
827 Archive->Restore(0x0002,0x0010);
830 void FileHelper::SetWriteToLibido()
832 ValEntry *oldRow = dynamic_cast<ValEntry *>
833 (HeaderInternal->GetDocEntry(0x0028, 0x0010));
834 ValEntry *oldCol = dynamic_cast<ValEntry *>
835 (HeaderInternal->GetDocEntry(0x0028, 0x0011));
837 if( oldRow && oldCol )
839 std::string rows, columns;
841 ValEntry *newRow=new ValEntry(oldRow->GetDictEntry());
842 ValEntry *newCol=new ValEntry(oldCol->GetDictEntry());
844 newRow->Copy(oldCol);
845 newCol->Copy(oldRow);
847 newRow->SetValue(oldCol->GetValue());
848 newCol->SetValue(oldRow->GetValue());
850 Archive->Push(newRow);
851 Archive->Push(newCol);
854 ValEntry *libidoCode = CopyValEntry(0x0008,0x0010);
855 libidoCode->SetValue("ACRNEMA_LIBIDO_1.1");
856 Archive->Push(libidoCode);
862 void FileHelper::SetWriteToNoLibido()
864 ValEntry *recCode = dynamic_cast<ValEntry *>
865 (HeaderInternal->GetDocEntry(0x0008,0x0010));
868 if( recCode->GetValue() == "ACRNEMA_LIBIDO_1.1" )
870 ValEntry *libidoCode = CopyValEntry(0x0008,0x0010);
871 libidoCode->SetValue("");
872 Archive->Push(libidoCode);
880 void FileHelper::RestoreWriteOfLibido()
882 Archive->Restore(0x0028,0x0010);
883 Archive->Restore(0x0028,0x0011);
884 Archive->Restore(0x0008,0x0010);
887 ValEntry *FileHelper::CopyValEntry(uint16_t group,uint16_t elem)
889 DocEntry *oldE = HeaderInternal->GetDocEntry(group, elem);
894 newE = new ValEntry(oldE->GetDictEntry());
899 newE = GetHeader()->NewValEntry(group,elem);
906 * \brief Modifies the value of a given Bin Entry (Dicom Element)
907 * when it exists. Create it with the given value when unexistant.
908 * @param content (string) Value to be set
909 * @param group Group number of the Entry
910 * @param elem Element number of the Entry
911 * \return pointer to the modified/created Bin Entry (NULL when creation
914 BinEntry *FileHelper::CopyBinEntry(uint16_t group,uint16_t elem)
916 DocEntry *oldE = HeaderInternal->GetDocEntry(group, elem);
921 newE = new BinEntry(oldE->GetDictEntry());
926 newE = GetHeader()->NewBinEntry(group,elem);
932 //-----------------------------------------------------------------------------
935 * \brief Factorization for various forms of constructors.
937 void FileHelper::Initialise()
939 WriteMode = WMODE_RAW;
940 WriteType = ExplicitVR;
942 PixelReadConverter = new PixelReadConvert;
943 PixelWriteConverter = new PixelWriteConvert;
944 Archive = new DocEntryArchive( HeaderInternal );
946 if ( HeaderInternal->IsReadable() )
948 PixelReadConverter->GrabInformationsFromHeader( HeaderInternal );
955 uint8_t *FileHelper::GetRaw()
957 uint8_t *raw = PixelReadConverter->GetRaw();
960 // The Raw image migth not be loaded yet:
961 std::ifstream *fp = HeaderInternal->OpenFile();
962 PixelReadConverter->ReadAndDecompressPixelData( fp );
964 HeaderInternal->CloseFile();
966 raw = PixelReadConverter->GetRaw();
969 gdcmVerboseMacro( "Read/decompress of pixel data apparently went wrong.");
977 //-----------------------------------------------------------------------------
980 //-----------------------------------------------------------------------------
981 } // end namespace gdcm