1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2004/12/10 13:49:07 $
7 Version: $Revision: 1.86 $
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"
29 class PixelReadConvert;
30 class PixelWriteConvert;
31 class DocEntryArchive;
32 //-----------------------------------------------------------------------------
34 * In addition to Dicom header exploration, this class is designed
35 * for accessing the image/volume content. One can also use it to
36 * write Dicom/ACR-NEMA/RAW files.
38 class GDCM_EXPORT File
49 File( Header* header );
50 File( std::string const& filename );
54 /// Accessor to \ref Header
55 Header* GetHeader() { return HeaderInternal; }
57 size_t GetImageDataSize();
58 size_t GetImageDataRawSize();
60 uint8_t* GetImageData();
61 uint8_t* GetImageDataRaw();
62 size_t GetImageDataIntoVector(void* destination, size_t maxSize);
64 void SetImageData(uint8_t* data, size_t expectedSize);
67 void SetUserData(uint8_t* data, size_t expectedSize);
68 uint8_t* GetUserData();
69 size_t GetUserDataSize();
70 // RBG datas (from file
71 uint8_t* GetRGBData();
72 size_t GetRGBDataSize();
73 // RAW datas (from file
74 uint8_t* GetRawData();
75 size_t GetRawDataSize();
77 // Write pixels of ONE image on hard drive
78 // No test is made on processor "endianity"
79 // The user must call his reader correctly
80 bool WriteRawData (std::string const& fileName);
81 bool WriteDcmImplVR(std::string const& fileName);
82 bool WriteDcmExplVR(std::string const& fileName);
83 bool WriteAcr (std::string const& fileName);
84 bool Write(std::string const& fileName);
86 bool SetEntryByNumber(std::string const& content,
87 uint16_t group, uint16_t element);
88 bool SetEntryByNumber(uint8_t* content, int lgth,
89 uint16_t group, uint16_t element);
90 bool ReplaceOrCreateByNumber(std::string const& content,
91 uint16_t group, uint16_t element);
92 bool ReplaceOrCreateByNumber(uint8_t* binArea, int lgth,
93 uint16_t group, uint16_t elem);
95 uint8_t* GetLutRGBA();
98 void SetWriteModeToRaw() { SetWriteMode(WMODE_RAW); };
99 void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); };
100 void SetWriteMode(FileMode mode) { WriteMode = mode; };
101 FileMode GetWriteMode() { return WriteMode; };
104 void SetWriteTypeToDcmImplVR() { SetWriteType(ImplicitVR); };
105 void SetWriteTypeToDcmExplVR() { SetWriteType(ExplicitVR); };
106 void SetWriteTypeToAcr() { SetWriteType(ACR); };
107 void SetWriteTypeToAcrLibido() { SetWriteType(ACR_LIBIDO); };
108 void SetWriteType(FileType format) { WriteType = format; };
109 FileType GetWriteType() { return WriteType; };
112 bool WriteBase(std::string const& fileName);
113 bool CheckWriteIntegrity();
115 void SetWriteToRaw();
116 void SetWriteToRGB();
119 void SetWriteFileTypeToACR();
120 void SetWriteFileTypeToExplicitVR();
121 void SetWriteFileTypeToImplicitVR();
122 void RestoreWriteFileType();
124 void SetWriteToLibido();
125 void SetWriteToNoLibido();
126 void RestoreWriteOfLibido();
128 ValEntry* CopyValEntry(uint16_t group,uint16_t element);
129 BinEntry* CopyBinEntry(uint16_t group,uint16_t element);
137 // members variables:
139 /// Header to use to load the file
140 Header *HeaderInternal;
142 /// \brief Whether the underlying \ref Header was loaded by
143 /// the constructor or passed to the constructor. When false
144 /// the destructor is in charge of deletion.
147 /// Wether already parsed or not
150 /// Utility pixel converter
151 PixelReadConvert* PixelReadConverter;
152 PixelWriteConvert* PixelWriteConverter;
154 // Utility header archive
155 DocEntryArchive *Archive;
161 } // end namespace gdcm
163 //-----------------------------------------------------------------------------