1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2004/11/24 16:39:18 $
7 Version: $Revision: 1.75 $
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 "gdcmPixelConvert.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
53 File( Header* header );
54 File( std::string const& filename );
58 /// Accessor to \ref Header
59 Header* GetHeader() { return HeaderInternal; }
61 /// Accessor to \ref ImageDataSize
62 size_t GetImageDataSize();
63 /// Accessor to \ref ImageDataSizeRaw
64 size_t GetImageDataSizeRaw();
66 /// Accessor to \ref PixelConverter
67 PixelConvert* GetPixelConverter() { return PixelConverter; };
69 uint8_t* GetImageData();
70 size_t GetImageDataIntoVector(void* destination, size_t maxSize);
71 uint8_t* GetImageDataRaw();
73 // see also Header::SetImageDataSize ?!?
74 bool SetImageData (uint8_t* data, size_t expectedSize);
76 // Write pixels of ONE image on hard drive
77 // No test is made on processor "endianity"
78 // The user must call his reader correctly
79 bool WriteRawData (std::string const& fileName);
80 bool WriteDcmImplVR(std::string const& fileName);
81 bool WriteDcmExplVR(std::string const& fileName);
82 bool WriteAcr (std::string const& fileName);
83 bool Write(std::string const& fileName);
85 virtual bool SetEntryByNumber(std::string const& content,
86 uint16_t group, uint16_t element)
88 HeaderInternal->SetEntryByNumber(content,group,element);
91 uint8_t* GetLutRGBA();
94 void SetWriteModeToNative() { SetWriteMode(WMODE_NATIVE); };
95 void SetWriteModeToDecompressed() { SetWriteMode(WMODE_DECOMPRESSED); };
96 void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); };
97 void SetWriteMode(unsigned int mode) { WriteMode = mode; };
98 unsigned int GetWriteMode() { return WriteMode; };
101 void SetWriteTypeToDcmImplVR() { SetWriteType(WTYPE_EXPL_VR); };
102 void SetWriteTypeToDcmExplVR() { SetWriteType(WTYPE_EXPL_VR); };
103 void SetWriteTypeToAcr() { SetWriteType(WTYPE_ACR); };
104 void SetWriteType(unsigned int format) { WriteType = format; };
105 unsigned int GetWriteType() { return WriteType; };
108 bool WriteBase(std::string const& fileName, FileType type);
110 void SetWriteToNative();
111 void SetWriteToDecompressed();
112 void SetWriteToRGB();
115 void SetWriteToLibido();
116 void RestoreWriteFromLibido();
118 ValEntry* CopyValEntry(uint16_t group,uint16_t element);
119 BinEntry* CopyBinEntry(uint16_t group,uint16_t element);
124 void SaveInitialValues(); // will belong to the future PixelData class
125 uint8_t* GetDecompressed();
126 int ComputeDecompressedPixelDataSizeFromHeader();
129 void SetPixelData(uint8_t* data);
131 // members variables:
133 /// Header to use to load the file
134 Header *HeaderInternal;
136 /// \brief Whether the underlying \ref Header was loaded by
137 /// the constructor or passed to the constructor. When false
138 /// the destructor is in charge of deletion.
141 /// Wether already parsed or not
144 /// Utility pixel converter
145 PixelConvert* PixelConverter;
147 // Utility header archive
148 DocEntryArchive *Archive;
151 unsigned int WriteMode;
152 unsigned int WriteType;
155 // --------------- Will be moved to a PixelData class
158 /// \brief to hold the Pixels (when read)
159 uint8_t* Pixel_Data; // (was PixelData)
161 /// \brief Size (in bytes) of required memory to hold the Gray Level pixels
162 /// represented in this file. This is used when the user DOESN'T want
163 /// the RGB pixels image when it's stored as a PALETTE COLOR image
164 size_t ImageDataSizeRaw;
166 /// \brief Size (in bytes) of requited memory to hold the the pixels
167 /// of this image in it's RGB convertion either from:
168 /// - Plane R, Plane G, Plane B
169 /// - Grey Plane + Palette Color
170 /// - YBR Pixels (or from RGB Pixels, as well)
171 size_t ImageDataSize;
173 /// \brief ==1 if GetImageDataRaw was used
174 /// ==0 if GetImageData was used
175 /// ==-1 if ImageData never read
179 // --------------- end of future PixelData class
183 } // end namespace gdcm
185 //-----------------------------------------------------------------------------