2 //-----------------------------------------------------------------------------
6 #include "gdcmCommon.h"
7 #include "gdcmHeader.h"
9 //-----------------------------------------------------------------------------
11 * In addition to Dicom header exploration, this class is designed
12 * for accessing the image/volume content. One can also use it to
13 * write Dicom/ACR-NEMA/RAW files.
15 class GDCM_EXPORT gdcmFile
18 gdcmFile(gdcmHeader *header);
19 gdcmFile(std::string & filename,
20 bool exception_on_error = false,
21 bool enable_sequences = false,
22 bool skip_shadow = false);
24 gdcmFile(const char * filename,
25 bool exception_on_error = false,
26 bool enable_sequences = false,
27 bool skip_shadow = false);
29 virtual ~gdcmFile(void);
31 gdcmHeader *GetHeader(void);
33 // For promotion (performs a deepcopy of pointed header object)
34 // TODO Swig gdcmFile(gdcmHeader* header);
35 // TODO Swig ~gdcmFile();
37 // On writing purposes. When instance was created through
38 // gdcmFile(std::string filename) then the filename argument MUST be
39 // different from the constructor's one (no overwriting allowed).
40 // TODO Swig int SetFileName(std::string filename);
42 void SetPixelDataSizeFromHeader(void);
43 size_t GetImageDataSize();
44 size_t GetImageDataSizeRaw();
46 void * GetImageData();
47 size_t GetImageDataIntoVector(void* destination, size_t MaxSize);
48 void * GetImageDataRaw();
49 size_t GetImageDataIntoVectorRaw(void* destination, size_t MaxSize);
51 // Allocates ExpectedSize bytes of memory at this->Data and copies the
52 // pointed data to it. Copying the image might look useless but
53 // the caller might destroy it's image (without knowing it: think
54 // of a complicated interface where display is done with a library
55 // e.g. VTK) before calling the Write
57 // voir gdcmHeader::SetImageDataSize ?!?
58 bool SetImageData (void * Data, size_t ExpectedSize);
59 // When the caller is aware we simply point to the data:
60 // TODO int SetImageDataNoCopy (void * Data, size_t ExpectedSize);
63 // A NE PAS OUBLIER : que fait-on en cas de Transfert Syntax (dans l'entete)
64 // incohérente avec l'ordre des octets en mémoire ?
65 // TODO Swig int Write();
67 // Write pixels of ONE image on hard drive
68 // No test is made on processor "endianity"
69 // The user must call his reader correctly
70 bool WriteRawData (std::string fileName);
71 bool WriteDcmImplVR(std::string fileName);
72 bool WriteDcmImplVR(const char * fileName);
73 bool WriteDcmExplVR(std::string fileName);
74 bool WriteAcr (std::string fileName);
76 // Body in file gdcmParse.cxx
77 bool ParsePixelData(void);
79 inline virtual bool SetEntryByNumber(std::string content,
80 guint16 group, guint16 element)
81 { GetHeader()->SetEntryByNumber(content,group,element); }
85 bool WriteBase(std::string 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
120 /// \brief Area length to receive the RGB pixels
121 /// from Grey Plane + Palette Color
124 /// \brief ==1 if GetImageDataRaw was used
125 /// ==0 if GetImageData was used
126 /// ==-1 if ImageData never read
129 /// weather already parsed
132 /// To avoid file overwrite
133 std::string OrigFileName;
136 //-----------------------------------------------------------------------------