1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2004/10/13 14:15:30 $
7 Version: $Revision: 1.62 $
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 uint8_t* GetImageData();
55 size_t GetImageDataIntoVector(void* destination, size_t maxSize);
56 uint8_t* GetImageDataRaw();
57 void GetImageDataIntoVectorRaw(void* destination, size_t maxSize);
59 // see also Header::SetImageDataSize ?!?
60 bool SetImageData (uint8_t* data, size_t expectedSize);
62 /// \todo When the caller is aware we simply point to the data:
63 /// int SetImageDataNoCopy (void* Data, size_t ExpectedSize);
65 // Write pixels of ONE image on hard drive
66 // No test is made on processor "endianity"
67 // The user must call his reader correctly
68 bool WriteRawData (std::string const& fileName);
69 bool WriteDcmImplVR(std::string const& fileName);
70 bool WriteDcmExplVR(std::string const& fileName);
71 bool WriteAcr (std::string const& fileName);
73 // Don't look any longer for the code :
74 // It's in file gdcmParsePixels.cxx
75 bool ParsePixelData();
77 virtual bool SetEntryByNumber(std::string const& content,
78 uint16_t group, uint16_t element)
80 HeaderInternal->SetEntryByNumber(content,group,element);
85 bool WriteBase(std::string const& fileName, FileType type);
90 // For JPEG 8 Bits, body in file gdcmJpeg.cxx
91 bool gdcm_write_JPEG_file (FILE* fp, void* image_buffer,
92 int image_width, int image_heigh,
95 // For JPEG 12 Bits, body in file gdcmJpeg12.cxx
96 bool gdcm_write_JPEG_file12 (FILE* fp, void* image_buffer,
97 int image_width, int image_height,
100 void SaveInitialValues(); // will belong to the future PixelData class
101 void RestoreInitialValues(); // will belong to the future PixelData class
102 void DeleteInitialValues(); // will belong to the future PixelData class
104 // members variables:
106 /// Header to use to load the file
107 Header *HeaderInternal;
109 /// \brief Whether the underlying \ref Header was loaded by
110 /// the constructor or passed to the constructor. When false
111 /// the destructor is in charge of deletion.
114 /// wether already parsed
118 PixelConvert PixelConverter;
120 // --------------- Will be moved to a PixelData class
123 /// \brief to hold the Pixels (when read)
124 uint8_t* Pixel_Data; // (was PixelData)
126 /// \brief Size (in bytes) of required memory to hold the Gray Level pixels
127 /// represented in this file. This is used when the user DOESN'T want
128 /// the RGB pixels image when it's stored as a PALETTE COLOR image
129 size_t ImageDataSizeRaw;
131 /// \brief Size (in bytes) of requited memory to hold the the pixels
132 /// of this image in it's RGB convertion either from:
133 /// - Plane R, Plane G, Plane B
134 /// - Grey Plane + Palette Color
135 /// - YBR Pixels (or from RGB Pixels, as well)
136 size_t ImageDataSize;
138 /// \brief ==1 if GetImageDataRaw was used
139 /// ==0 if GetImageData was used
140 /// ==-1 if ImageData never read
143 /// \brief length of the last allocated area devoided to receive Pixels
144 /// ( to allow us not to (free + new) if un necessary )
145 size_t LastAllocatedPixelDataLength;
147 // Initial values of some fields that can be modified during reading process
148 // if user asked to transform gray level + LUT image into RGB image
150 /// \brief Samples Per Pixel (0x0028,0x0002), as found on disk
151 std::string InitialSpp;
152 /// \brief Photometric Interpretation (0x0028,0x0004), as found on disk
153 std::string InitialPhotInt;
154 /// \brief Planar Configuration (0x0028,0x0006), as found on disk
155 std::string InitialPlanConfig;
157 // Initial values of some fields that can be modified during reading process
158 // if the image was a 'strange' ACR-NEMA
159 // (Bits Allocated=12, High Bit not equal to Bits stored +1)
160 /// \brief Bits Allocated (0x0028,0x0100), as found on disk
161 std::string InitialBitsAllocated;
162 /// \brief High Bit (0x0028,0x0102), as found on disk
163 std::string InitialHighBit;
165 // some DocEntry that can be moved out of the H table during reading process
166 // if user asked to transform gray level + LUT image into RGB image
167 // We keep a pointer on them for a future use.
169 /// \brief Red Palette Color Lookup Table Descriptor 0028 1101 as read
170 DocEntry* InitialRedLUTDescr;
171 /// \brief Green Palette Color Lookup Table Descriptor 0028 1102 as read
172 DocEntry* InitialGreenLUTDescr;
173 /// \brief Blue Palette Color Lookup Table Descriptor 0028 1103 as read
174 DocEntry* InitialBlueLUTDescr;
176 /// \brief Red Palette Color Lookup Table Data 0028 1201 as read
177 DocEntry* InitialRedLUTData;
178 /// \brief Green Palette Color Lookup Table Data 0028 1202 as read
179 DocEntry* InitialGreenLUTData;
180 /// \brief Blue Palette Color Lookup Table Data 0028 1203 as read
181 DocEntry* InitialBlueLUTData;
184 // --------------- end of future PixelData class
188 } // end namespace gdcm
190 //-----------------------------------------------------------------------------