1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2004/12/03 10:21:54 $
7 Version: $Revision: 1.80 $
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 "gdcmDocEntryArchive.h"
29 //-----------------------------------------------------------------------------
31 * In addition to Dicom header exploration, this class is designed
32 * for accessing the image/volume content. One can also use it to
33 * write Dicom/ACR-NEMA/RAW files.
35 class GDCM_EXPORT File
52 File( Header* header );
53 File( std::string const& filename );
57 /// Accessor to \ref Header
58 Header* GetHeader() { return HeaderInternal; }
60 size_t GetImageDataSize();
61 size_t GetImageDataRawSize();
63 /// Accessor to \ref PixelReadConverter
64 PixelReadConvert* GetPixelReadConverter() { return PixelReadConverter; };
66 uint8_t* GetImageData();
67 uint8_t* GetImageDataRaw();
68 size_t GetImageDataIntoVector(void* destination, size_t maxSize);
70 bool SetImageData (uint8_t* data, size_t expectedSize);
72 // Write pixels of ONE image on hard drive
73 // No test is made on processor "endianity"
74 // The user must call his reader correctly
75 bool WriteRawData (std::string const& fileName);
76 bool WriteDcmImplVR(std::string const& fileName);
77 bool WriteDcmExplVR(std::string const& fileName);
78 bool WriteAcr (std::string const& fileName);
79 bool Write(std::string const& fileName);
81 virtual bool SetEntryByNumber(std::string const& content,
82 uint16_t group, uint16_t element)
84 HeaderInternal->SetEntryByNumber(content,group,element);
87 uint8_t* GetLutRGBA();
90 void SetWriteModeToDecompressed() { SetWriteMode(WMODE_DECOMPRESSED); };
91 void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); };
92 void SetWriteMode(unsigned int mode) { WriteMode = mode; };
93 unsigned int GetWriteMode() { return WriteMode; };
96 void SetWriteTypeToDcmImplVR() { SetWriteType(WTYPE_EXPL_VR); };
97 void SetWriteTypeToDcmExplVR() { SetWriteType(WTYPE_EXPL_VR); };
98 void SetWriteTypeToAcr() { SetWriteType(WTYPE_ACR); };
99 void SetWriteType(unsigned int format) { WriteType = format; };
100 unsigned int GetWriteType() { return WriteType; };
103 bool WriteBase(std::string const& fileName, FileType type);
104 bool CheckWriteIntegrity();
106 void SetWriteToDecompressed();
107 void SetWriteToRGB();
110 void SetWriteFileTypeToACR();
111 void SetWriteFileTypeToExplicitVR();
112 void SetWriteFileTypeToImplicitVR();
113 void RestoreWriteFileType();
115 void SetWriteToLibido();
116 void SetWriteToNoLibido();
117 void RestoreWriteOfLibido();
119 ValEntry* CopyValEntry(uint16_t group,uint16_t element);
120 BinEntry* CopyBinEntry(uint16_t group,uint16_t element);
125 uint8_t* GetDecompressed();
126 int ComputeDecompressedPixelDataSizeFromHeader();
129 // members variables:
131 /// Header to use to load the file
132 Header *HeaderInternal;
134 /// \brief Whether the underlying \ref Header was loaded by
135 /// the constructor or passed to the constructor. When false
136 /// the destructor is in charge of deletion.
139 /// Wether already parsed or not
142 /// Utility pixel converter
143 PixelReadConvert* PixelReadConverter;
145 // Utility header archive
146 DocEntryArchive *Archive;
149 unsigned int WriteMode;
150 unsigned int WriteType;
153 // --------------- Will be moved to a PixelData class
156 /// \brief to hold the Pixels (when read)
157 uint8_t* Pixel_Data; // (was PixelData)
159 /// \brief Size (in bytes) of requited memory to hold the the pixels
160 /// of this image in it's RGB convertion either from:
161 /// - Plane R, Plane G, Plane B
162 /// - Grey Plane + Palette Color
163 /// - YBR Pixels (or from RGB Pixels, as well)
164 size_t ImageDataSize;
167 // --------------- end of future PixelData class
171 } // end namespace gdcm
173 //-----------------------------------------------------------------------------