1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2004/12/03 11:55:38 $
7 Version: $Revision: 1.81 $
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
53 File( Header* header );
54 File( std::string const& filename );
58 /// Accessor to \ref Header
59 Header* GetHeader() { return HeaderInternal; }
61 size_t GetImageDataSize();
62 size_t GetImageDataRawSize();
64 uint8_t* GetImageData();
65 uint8_t* GetImageDataRaw();
66 size_t GetImageDataIntoVector(void* destination, size_t maxSize);
68 bool SetImageData (uint8_t* data, size_t expectedSize);
70 // Write pixels of ONE image on hard drive
71 // No test is made on processor "endianity"
72 // The user must call his reader correctly
73 bool WriteRawData (std::string const& fileName);
74 bool WriteDcmImplVR(std::string const& fileName);
75 bool WriteDcmExplVR(std::string const& fileName);
76 bool WriteAcr (std::string const& fileName);
77 bool Write(std::string const& fileName);
79 virtual bool SetEntryByNumber(std::string const& content,
80 uint16_t group, uint16_t element)
82 HeaderInternal->SetEntryByNumber(content,group,element);
85 uint8_t* GetLutRGBA();
88 void SetWriteModeToDecompressed() { SetWriteMode(WMODE_DECOMPRESSED); };
89 void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); };
90 void SetWriteMode(unsigned int mode) { WriteMode = mode; };
91 unsigned int GetWriteMode() { return WriteMode; };
94 void SetWriteTypeToDcmImplVR() { SetWriteType(WTYPE_EXPL_VR); };
95 void SetWriteTypeToDcmExplVR() { SetWriteType(WTYPE_EXPL_VR); };
96 void SetWriteTypeToAcr() { SetWriteType(WTYPE_ACR); };
97 void SetWriteType(unsigned int format) { WriteType = format; };
98 unsigned int GetWriteType() { return WriteType; };
101 bool WriteBase(std::string const& fileName, FileType type);
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;
148 unsigned int WriteMode;
149 unsigned int WriteType;
151 } // end namespace gdcm
153 //-----------------------------------------------------------------------------