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