1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2004/12/03 14:22:40 $
7 Version: $Revision: 1.82 $
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 =========================================================================*/
22 #include "gdcmCommon.h"
23 #include "gdcmHeader.h"
24 #include "gdcmPixelReadConvert.h"
25 #include "gdcmPixelWriteConvert.h"
26 #include "gdcmDocEntryArchive.h"
30 //-----------------------------------------------------------------------------
32 * In addition to Dicom header exploration, this class is designed
33 * for accessing the image/volume content. One can also use it to
34 * write Dicom/ACR-NEMA/RAW files.
36 class GDCM_EXPORT File
46 File( Header* header );
47 File( std::string const& filename );
51 /// Accessor to \ref Header
52 Header* GetHeader() { return HeaderInternal; }
54 size_t GetImageDataSize();
55 size_t GetImageDataRawSize();
57 uint8_t* GetImageData();
58 uint8_t* GetImageDataRaw();
59 size_t GetImageDataIntoVector(void* destination, size_t maxSize);
61 bool SetImageData (uint8_t* data, size_t expectedSize);
63 // Write pixels of ONE image on hard drive
64 // No test is made on processor "endianity"
65 // The user must call his reader correctly
66 bool WriteRawData (std::string const& fileName);
67 bool WriteDcmImplVR(std::string const& fileName);
68 bool WriteDcmExplVR(std::string const& fileName);
69 bool WriteAcr (std::string const& fileName);
70 bool Write(std::string const& fileName);
72 virtual bool SetEntryByNumber(std::string const& content,
73 uint16_t group, uint16_t element)
75 HeaderInternal->SetEntryByNumber(content,group,element);
78 uint8_t* GetLutRGBA();
81 void SetWriteModeToDecompressed() { SetWriteMode(WMODE_DECOMPRESSED); };
82 void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); };
83 void SetWriteMode(WriteMode mode) { WriteMode = mode; };
84 WriteMode GetWriteMode() { return WriteMode; };
87 void SetWriteTypeToDcmImplVR() { SetWriteType(ImplicitVR); };
88 void SetWriteTypeToDcmExplVR() { SetWriteType(ExplicitVR); };
89 void SetWriteTypeToAcr() { SetWriteType(ACR); };
90 void SetWriteTypeToAcrLibido() { SetWriteType(ACR_LIBIDO); };
91 void SetWriteType(FileType format) { WriteType = format; };
92 FileType GetWriteType() { return WriteType; };
95 bool WriteBase(std::string const& fileName);
96 bool CheckWriteIntegrity();
98 void SetWriteToDecompressed();
102 void SetWriteFileTypeToACR();
103 void SetWriteFileTypeToExplicitVR();
104 void SetWriteFileTypeToImplicitVR();
105 void RestoreWriteFileType();
107 void SetWriteToLibido();
108 void SetWriteToNoLibido();
109 void RestoreWriteOfLibido();
111 ValEntry* CopyValEntry(uint16_t group,uint16_t element);
112 BinEntry* CopyBinEntry(uint16_t group,uint16_t element);
117 uint8_t* GetDecompressed();
118 int ComputeDecompressedPixelDataSizeFromHeader();
121 // members variables:
123 /// Header to use to load the file
124 Header *HeaderInternal;
126 /// \brief Whether the underlying \ref Header was loaded by
127 /// the constructor or passed to the constructor. When false
128 /// the destructor is in charge of deletion.
131 /// Wether already parsed or not
134 /// Utility pixel converter
135 PixelReadConvert* PixelReadConverter;
136 PixelWriteConvert* PixelWriteConverter;
138 // Utility header archive
139 DocEntryArchive *Archive;
145 } // end namespace gdcm
147 //-----------------------------------------------------------------------------