1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2004/07/30 11:40:13 $
7 Version: $Revision: 1.39 $
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.htm 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"
25 //-----------------------------------------------------------------------------
27 * In addition to Dicom header exploration, this class is designed
28 * for accessing the image/volume content. One can also use it to
29 * write Dicom/ACR-NEMA/RAW files.
31 class GDCM_EXPORT gdcmFile
34 gdcmFile(gdcmHeader *header);
35 gdcmFile(std::string const & filename,
36 bool exception_on_error = false,
37 bool skip_shadow = false);
41 /// Accessor to \ref Header
42 gdcmHeader* GetHeader() { return Header; }
44 void SetPixelDataSizeFromHeader();
45 size_t GetImageDataSize();
46 size_t GetImageDataSizeRaw();
48 void * GetImageData();
49 size_t GetImageDataIntoVector(void* destination, size_t maxSize);
50 void * GetImageDataRaw();
51 size_t GetImageDataIntoVectorRaw(void* destination, size_t maxSize);
53 // Allocates ExpectedSize bytes of memory at this->Data and copies the
54 // pointed data to it. Copying the image might look useless but
55 // the caller might destroy it's image (without knowing it: think
56 // of a complicated interface where display is done with a library
57 // e.g. VTK) before calling the Write
59 // voir gdcmHeader::SetImageDataSize ?!?
60 bool SetImageData (void * 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 Header->SetEntryByNumber(content,group,element);
85 bool WriteBase(std::string const & fileName, FileType type);
88 void SwapZone(void* im, int swap, int lgr, int nb);
90 bool ReadPixelData(void * destination);
92 // For JPEG 8 Bits, body in file gdcmJpeg.cxx
93 bool gdcm_read_JPEG_file (FILE *fp, void * image_buffer);
94 static int gdcm_read_RLE_fragment(char **areaToRead, long lengthToDecode,
95 long uncompressedSegmentSize, FILE *fp);
96 // For JPEG 12 Bits, body in file gdcmJpeg12.cxx
97 bool gdcm_read_JPEG_file12 (FILE *fp, void* image_buffer);
98 // For JPEG 2000, body in file gdcmJpeg2000.cxx
99 bool gdcm_read_JPEG2000_file (FILE *fp, void* image_buffer);
101 // For Run Length Encoding (TOCHECK)
102 bool gdcm_read_RLE_file (FILE *fp, void* image_buffer);
106 /// \brief Header to use to load the file
109 /// \brief Whether the underlying \ref gdcmHeader was loaded by
110 /// the constructor or passed to the constructor. When false
111 /// the destructor is in charge of deletion.
114 /// \brief to hold the Pixels (when read)
117 /// \brief Area length to receive the pixels
118 size_t ImageDataSizeRaw;
120 /// \brief Area length to receive the RGB pixels
121 /// from Grey Plane + Palette Color
122 size_t ImageDataSize;
124 /// \brief ==1 if GetImageDataRaw was used
125 /// ==0 if GetImageData was used
126 /// ==-1 if ImageData never read
129 /// wether already parsed
133 //-----------------------------------------------------------------------------