1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2004/11/24 10:23:47 $
7 Version: $Revision: 1.74 $
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() { return ImageDataSize; };
64 /// Accessor to \ref ImageDataSizeRaw
65 size_t GetImageDataSizeRaw() { return ImageDataSizeRaw; };
67 /// Accessor to \ref PixelConverter
68 PixelConvert* GetPixelConverter() { return PixelConverter; };
70 uint8_t* GetImageData();
71 size_t GetImageDataIntoVector(void* destination, size_t maxSize);
72 uint8_t* GetImageDataRaw();
74 // see also Header::SetImageDataSize ?!?
75 bool SetImageData (uint8_t* data, size_t expectedSize);
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 virtual bool SetEntryByNumber(std::string const& content,
87 uint16_t group, uint16_t element)
89 HeaderInternal->SetEntryByNumber(content,group,element);
92 uint8_t* GetLutRGBA();
95 void SetWriteModeToNative() { SetWriteMode(WMODE_NATIVE); };
96 void SetWriteModeToDecompressed() { SetWriteMode(WMODE_DECOMPRESSED); };
97 void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); };
98 void SetWriteMode(unsigned int mode) { WriteMode = mode; };
99 unsigned int GetWriteMode() { return WriteMode; };
102 void SetWriteTypeToDcmImplVR() { SetWriteType(WTYPE_EXPL_VR); };
103 void SetWriteTypeToDcmExplVR() { SetWriteType(WTYPE_EXPL_VR); };
104 void SetWriteTypeToAcr() { SetWriteType(WTYPE_ACR); };
105 void SetWriteType(unsigned int format) { WriteType = format; };
106 unsigned int GetWriteType() { return WriteType; };
109 bool WriteBase(std::string const& fileName, FileType type);
111 void SetWriteToNative();
112 void SetWriteToDecompressed();
113 void SetWriteToRGB();
116 void SetWriteToLibido();
117 void RestoreWriteFromLibido();
119 ValEntry* CopyValEntry(uint16_t group,uint16_t element);
120 BinEntry* CopyBinEntry(uint16_t group,uint16_t element);
125 void SaveInitialValues(); // will belong to the future PixelData class
126 uint8_t* GetDecompressed();
127 int ComputeDecompressedPixelDataSizeFromHeader();
130 void SetPixelData(uint8_t* data);
132 // members variables:
134 /// Header to use to load the file
135 Header *HeaderInternal;
137 /// \brief Whether the underlying \ref Header was loaded by
138 /// the constructor or passed to the constructor. When false
139 /// the destructor is in charge of deletion.
142 /// Wether already parsed or not
145 /// Utility pixel converter
146 PixelConvert* PixelConverter;
148 // Utility header archive
149 DocEntryArchive *Archive;
152 unsigned int WriteMode;
153 unsigned int WriteType;
156 // --------------- Will be moved to a PixelData class
159 /// \brief to hold the Pixels (when read)
160 uint8_t* Pixel_Data; // (was PixelData)
162 /// \brief Size (in bytes) of required memory to hold the Gray Level pixels
163 /// represented in this file. This is used when the user DOESN'T want
164 /// the RGB pixels image when it's stored as a PALETTE COLOR image
165 size_t ImageDataSizeRaw;
167 /// \brief Size (in bytes) of requited memory to hold the the pixels
168 /// of this image in it's RGB convertion either from:
169 /// - Plane R, Plane G, Plane B
170 /// - Grey Plane + Palette Color
171 /// - YBR Pixels (or from RGB Pixels, as well)
172 size_t ImageDataSize;
174 /// \brief ==1 if GetImageDataRaw was used
175 /// ==0 if GetImageData was used
176 /// ==-1 if ImageData never read
180 // --------------- end of future PixelData class
184 } // end namespace gdcm
186 //-----------------------------------------------------------------------------