1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2004/12/07 17:28:50 $
7 Version: $Revision: 1.85 $
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 bool SetImageData (uint8_t* data, size_t expectedSize);
66 // Write pixels of ONE image on hard drive
67 // No test is made on processor "endianity"
68 // The user must call his reader correctly
69 bool WriteRawData (std::string const& fileName);
70 bool WriteDcmImplVR(std::string const& fileName);
71 bool WriteDcmExplVR(std::string const& fileName);
72 bool WriteAcr (std::string const& fileName);
73 bool Write(std::string const& fileName);
75 bool SetEntryByNumber(std::string const& content,
76 uint16_t group, uint16_t element);
77 bool SetEntryByNumber(uint8_t* content, int lgth,
78 uint16_t group, uint16_t element);
79 bool ReplaceOrCreateByNumber(std::string const& content,
80 uint16_t group, uint16_t element);
81 bool ReplaceOrCreateByNumber(uint8_t* binArea, int lgth,
82 uint16_t group, uint16_t elem);
84 uint8_t* GetLutRGBA();
87 void SetWriteModeToDecompressed() { SetWriteMode(WMODE_DECOMPRESSED); };
88 void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); };
89 void SetWriteMode(FileMode mode) { WriteMode = mode; };
90 FileMode GetWriteMode() { return WriteMode; };
93 void SetWriteTypeToDcmImplVR() { SetWriteType(ImplicitVR); };
94 void SetWriteTypeToDcmExplVR() { SetWriteType(ExplicitVR); };
95 void SetWriteTypeToAcr() { SetWriteType(ACR); };
96 void SetWriteTypeToAcrLibido() { SetWriteType(ACR_LIBIDO); };
97 void SetWriteType(FileType format) { WriteType = format; };
98 FileType GetWriteType() { return WriteType; };
101 bool WriteBase(std::string const& fileName);
102 bool CheckWriteIntegrity();
104 void SetWriteToDecompressed();
105 void SetWriteToRGB();
108 void SetWriteFileTypeToACR();
109 void SetWriteFileTypeToExplicitVR();
110 void SetWriteFileTypeToImplicitVR();
111 void RestoreWriteFileType();
113 void SetWriteToLibido();
114 void SetWriteToNoLibido();
115 void RestoreWriteOfLibido();
117 ValEntry* CopyValEntry(uint16_t group,uint16_t element);
118 BinEntry* CopyBinEntry(uint16_t group,uint16_t element);
123 uint8_t* GetDecompressed();
124 int ComputeDecompressedPixelDataSizeFromHeader();
127 // members variables:
129 /// Header to use to load the file
130 Header *HeaderInternal;
132 /// \brief Whether the underlying \ref Header was loaded by
133 /// the constructor or passed to the constructor. When false
134 /// the destructor is in charge of deletion.
137 /// Wether already parsed or not
140 /// Utility pixel converter
141 PixelReadConvert* PixelReadConverter;
142 PixelWriteConvert* PixelWriteConverter;
144 // Utility header archive
145 DocEntryArchive *Archive;
151 } // end namespace gdcm
153 //-----------------------------------------------------------------------------