1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2004/10/22 03:05:41 $
7 Version: $Revision: 1.65 $
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"
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
38 File( Header* header );
39 File( std::string const& filename );
43 /// Accessor to \ref Header
44 Header* GetHeader() { return HeaderInternal; }
46 int ComputeDecompressedPixelDataSizeFromHeader();
48 /// Accessor to \ref ImageDataSize
49 size_t GetImageDataSize(){ return ImageDataSize; };
51 /// Accessor to \ref ImageDataSizeRaw
52 size_t GetImageDataSizeRaw(){ return ImageDataSizeRaw; };
54 /// Accessor to \ref PixelConverter
55 PixelConvert* GetPixelConverter(){ return PixelConverter; };
57 uint8_t* GetImageData();
58 size_t GetImageDataIntoVector(void* destination, size_t maxSize);
59 uint8_t* GetImageDataRaw();
60 void GetImageDataIntoVectorRaw(void* destination, size_t maxSize);
62 // see also Header::SetImageDataSize ?!?
63 bool SetImageData (uint8_t* data, size_t expectedSize);
65 /// \todo When the caller is aware we simply point to the data:
66 /// int SetImageDataNoCopy (void* Data, size_t ExpectedSize);
68 // Write pixels of ONE image on hard drive
69 // No test is made on processor "endianity"
70 // The user must call his reader correctly
71 bool WriteRawData (std::string const& fileName);
72 bool WriteDcmImplVR(std::string const& fileName);
73 bool WriteDcmExplVR(std::string const& fileName);
74 bool WriteAcr (std::string const& fileName);
76 virtual bool SetEntryByNumber(std::string const& content,
77 uint16_t group, uint16_t element)
79 HeaderInternal->SetEntryByNumber(content,group,element);
82 uint8_t* GetLutRGBA();
85 bool WriteBase(std::string const& fileName, FileType type);
90 void SaveInitialValues(); // will belong to the future PixelData class
91 void RestoreInitialValues(); // will belong to the future PixelData class
92 void DeleteInitialValues(); // will belong to the future PixelData class
97 /// Header to use to load the file
98 Header *HeaderInternal;
100 /// \brief Whether the underlying \ref Header was loaded by
101 /// the constructor or passed to the constructor. When false
102 /// the destructor is in charge of deletion.
105 /// Wether already parsed or not
108 /// Utility pixel converter
109 PixelConvert* PixelConverter;
112 // --------------- Will be moved to a PixelData class
115 /// \brief to hold the Pixels (when read)
116 uint8_t* Pixel_Data; // (was PixelData)
118 /// \brief Size (in bytes) of required memory to hold the Gray Level pixels
119 /// represented in this file. This is used when the user DOESN'T want
120 /// the RGB pixels image when it's stored as a PALETTE COLOR image
121 size_t ImageDataSizeRaw;
123 /// \brief Size (in bytes) of requited memory to hold the the pixels
124 /// of this image in it's RGB convertion either from:
125 /// - Plane R, Plane G, Plane B
126 /// - Grey Plane + Palette Color
127 /// - YBR Pixels (or from RGB Pixels, as well)
128 size_t ImageDataSize;
130 /// \brief ==1 if GetImageDataRaw was used
131 /// ==0 if GetImageData was used
132 /// ==-1 if ImageData never read
135 /// \brief length of the last allocated area devoided to receive Pixels
136 /// ( to allow us not to (free + new) if un necessary )
137 size_t LastAllocatedPixelDataLength;
139 // Initial values of some fields that can be modified during reading process
140 // if user asked to transform gray level + LUT image into RGB image
142 /// \brief Samples Per Pixel (0x0028,0x0002), as found on disk
143 std::string InitialSpp;
144 /// \brief Photometric Interpretation (0x0028,0x0004), as found on disk
145 std::string InitialPhotInt;
146 /// \brief Planar Configuration (0x0028,0x0006), as found on disk
147 std::string InitialPlanConfig;
149 // Initial values of some fields that can be modified during reading process
150 // if the image was a 'strange' ACR-NEMA
151 // (Bits Allocated=12, High Bit not equal to Bits stored +1)
152 /// \brief Bits Allocated (0x0028,0x0100), as found on disk
153 std::string InitialBitsAllocated;
154 /// \brief High Bit (0x0028,0x0102), as found on disk
155 std::string InitialHighBit;
157 // some DocEntry that can be moved out of the H table during reading process
158 // if user asked to transform gray level + LUT image into RGB image
159 // We keep a pointer on them for a future use.
161 /// \brief Red Palette Color Lookup Table Descriptor 0028 1101 as read
162 DocEntry* InitialRedLUTDescr;
163 /// \brief Green Palette Color Lookup Table Descriptor 0028 1102 as read
164 DocEntry* InitialGreenLUTDescr;
165 /// \brief Blue Palette Color Lookup Table Descriptor 0028 1103 as read
166 DocEntry* InitialBlueLUTDescr;
168 /// \brief Red Palette Color Lookup Table Data 0028 1201 as read
169 DocEntry* InitialRedLUTData;
170 /// \brief Green Palette Color Lookup Table Data 0028 1202 as read
171 DocEntry* InitialGreenLUTData;
172 /// \brief Blue Palette Color Lookup Table Data 0028 1203 as read
173 DocEntry* InitialBlueLUTData;
176 // --------------- end of future PixelData class
180 } // end namespace gdcm
182 //-----------------------------------------------------------------------------