1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2004/11/16 16:20:23 $
7 Version: $Revision: 1.69 $
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"
28 //-----------------------------------------------------------------------------
30 * In addition to Dicom header exploration, this class is designed
31 * for accessing the image/volume content. One can also use it to
32 * write Dicom/ACR-NEMA/RAW files.
34 class GDCM_EXPORT File
37 File( Header* header );
38 File( std::string const& filename );
42 /// Accessor to \ref Header
43 Header* GetHeader() { return HeaderInternal; }
45 /// Accessor to \ref ImageDataSize
46 size_t GetImageDataSize() { return ImageDataSize; };
48 /// Accessor to \ref ImageDataSizeRaw
49 size_t GetImageDataSizeRaw() { return ImageDataSizeRaw; };
51 /// Accessor to \ref PixelConverter
52 PixelConvert* GetPixelConverter() { return PixelConverter; };
54 uint8_t* GetImageData();
55 size_t GetImageDataIntoVector(void* destination, size_t maxSize);
56 uint8_t* GetImageDataRaw();
58 // see also Header::SetImageDataSize ?!?
59 bool SetImageData (uint8_t* data, size_t expectedSize);
61 // Write pixels of ONE image on hard drive
62 // No test is made on processor "endianity"
63 // The user must call his reader correctly
64 bool WriteRawData (std::string const& fileName);
65 bool WriteDcmImplVR(std::string const& fileName);
66 bool WriteDcmExplVR(std::string const& fileName);
67 bool WriteAcr (std::string const& fileName);
69 virtual bool SetEntryByNumber(std::string const& content,
70 uint16_t group, uint16_t element)
72 HeaderInternal->SetEntryByNumber(content,group,element);
75 uint8_t* GetLutRGBA();
78 bool WriteBase(std::string const& fileName, FileType type);
83 void SaveInitialValues(); // will belong to the future PixelData class
84 void RestoreInitialValues(); // will belong to the future PixelData class
85 void DeleteInitialValues(); // will belong to the future PixelData class
86 uint8_t* GetDecompressed();
87 int ComputeDecompressedPixelDataSizeFromHeader();
90 void SetPixelData(uint8_t* data);
94 /// Header to use to load the file
95 Header *HeaderInternal;
97 /// \brief Whether the underlying \ref Header was loaded by
98 /// the constructor or passed to the constructor. When false
99 /// the destructor is in charge of deletion.
102 /// Wether already parsed or not
105 /// Utility pixel converter
106 PixelConvert* PixelConverter;
109 // --------------- Will be moved to a PixelData class
112 /// \brief to hold the Pixels (when read)
113 uint8_t* Pixel_Data; // (was PixelData)
115 /// \brief Size (in bytes) of required memory to hold the Gray Level pixels
116 /// represented in this file. This is used when the user DOESN'T want
117 /// the RGB pixels image when it's stored as a PALETTE COLOR image
118 size_t ImageDataSizeRaw;
120 /// \brief Size (in bytes) of requited memory to hold the the pixels
121 /// of this image in it's RGB convertion either from:
122 /// - Plane R, Plane G, Plane B
123 /// - Grey Plane + Palette Color
124 /// - YBR Pixels (or from RGB Pixels, as well)
125 size_t ImageDataSize;
127 /// \brief ==1 if GetImageDataRaw was used
128 /// ==0 if GetImageData was used
129 /// ==-1 if ImageData never read
132 /// \brief length of the last allocated area devoided to receive Pixels
133 /// ( to allow us not to (free + new) if un necessary )
134 size_t LastAllocatedPixelDataLength;
136 // Initial values of some fields that can be modified during reading process
137 // if user asked to transform gray level + LUT image into RGB image
139 /// \brief Samples Per Pixel (0x0028,0x0002), as found on disk
140 std::string InitialSpp;
141 /// \brief Photometric Interpretation (0x0028,0x0004), as found on disk
142 std::string InitialPhotInt;
143 /// \brief Planar Configuration (0x0028,0x0006), as found on disk
144 std::string InitialPlanConfig;
146 // Initial values of some fields that can be modified during reading process
147 // if the image was a 'strange' ACR-NEMA
148 // (Bits Allocated=12, High Bit not equal to Bits stored +1)
149 /// \brief Bits Allocated (0x0028,0x0100), as found on disk
150 std::string InitialBitsAllocated;
151 /// \brief High Bit (0x0028,0x0102), as found on disk
152 std::string InitialHighBit;
154 // some DocEntry that can be moved out of the H table during reading process
155 // if user asked to transform gray level + LUT image into RGB image
156 // We keep a pointer on them for a future use.
158 /// \brief Red Palette Color Lookup Table Descriptor 0028 1101 as read
159 DocEntry* InitialRedLUTDescr;
160 /// \brief Green Palette Color Lookup Table Descriptor 0028 1102 as read
161 DocEntry* InitialGreenLUTDescr;
162 /// \brief Blue Palette Color Lookup Table Descriptor 0028 1103 as read
163 DocEntry* InitialBlueLUTDescr;
165 /// \brief Red Palette Color Lookup Table Data 0028 1201 as read
166 DocEntry* InitialRedLUTData;
167 /// \brief Green Palette Color Lookup Table Data 0028 1202 as read
168 DocEntry* InitialGreenLUTData;
169 /// \brief Blue Palette Color Lookup Table Data 0028 1203 as read
170 DocEntry* InitialBlueLUTData;
173 // --------------- end of future PixelData class
177 } // end namespace gdcm
179 //-----------------------------------------------------------------------------