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 gdcmFile(const char * filename);
21 virtual ~gdcmFile(void);
23 gdcmHeader *GetHeader(void);
25 // For promotion (performs a deepcopy of pointed header object)
26 // TODO Swig gdcmFile(gdcmHeader* header);
27 // TODO Swig ~gdcmFile();
29 // On writing purposes. When instance was created through
30 // gdcmFile(std::string filename) then the filename argument MUST be
31 // different from the constructor's one (no overwriting allowed).
32 // TODO Swig int SetFileName(std::string filename);
34 void SetPixelDataSizeFromHeader(void);
35 size_t GetImageDataSize();
36 size_t GetImageDataSizeRaw();
38 void * GetImageData();
39 size_t GetImageDataIntoVector(void* destination, size_t MaxSize);
40 void * GetImageDataRaw();
41 size_t GetImageDataIntoVectorRaw(void* destination, size_t MaxSize);
43 // Allocates ExpectedSize bytes of memory at this->Data and copies the
44 // pointed data to it. Copying the image might look useless but
45 // the caller might destroy it's image (without knowing it: think
46 // of a complicated interface where display is done with a library
47 // e.g. VTK) before calling the Write
49 // voir gdcmHeader::SetImageDataSize ?!?
50 bool SetImageData (void * Data, size_t ExpectedSize);
51 // When the caller is aware we simply point to the data:
52 // TODO int SetImageDataNoCopy (void * Data, size_t ExpectedSize);
55 // A NE PAS OUBLIER : que fait-on en cas de Transfert Syntax (dans l'entete)
56 // incohérente avec l'ordre des octets en mémoire ?
57 // TODO Swig int Write();
59 // Write pixels of ONE image on hard drive
60 // No test is made on processor "endianity"
61 // The user must call his reader correctly
62 bool WriteRawData (std::string fileName);
63 bool WriteDcmImplVR(std::string fileName);
64 bool WriteDcmImplVR(const char * fileName);
65 bool WriteDcmExplVR(std::string fileName);
66 bool WriteAcr (std::string fileName);
68 // Body in file gdcmParse.cxx
69 bool ParsePixelData(void);
72 bool WriteBase(std::string FileName, FileType type);
75 void SwapZone(void* im, int swap, int lgr, int nb);
77 bool ReadPixelData(void * destination);
79 // For JPEG 8 Bits, body in file gdcmJpeg.cxx
80 bool gdcm_read_JPEG_file (FILE *fp,void * image_buffer);
81 static int gdcm_read_RLE_fragment(char **areaToRead, long lengthToDecode,
82 long uncompressedSegmentSize,FILE *fp);
83 // For JPEG 12 Bits, body in file gdcmJpeg12.cxx
84 bool gdcm_read_JPEG_file12 (FILE *fp,void * image_buffer);
85 // For JPEG 2000, body in file gdcmJpeg2000.cxx
86 bool gdcm_read_JPEG2000_file (FILE *fp,void * image_buffer);
88 // For Run Length Encoding (TOCHECK)
89 bool gdcm_read_RLE_file (FILE *fp,void * image_buffer);
92 /// Header to use to load the file
98 /// Area length to receive the pixels
101 /// Area length to receive the RGB pixels
102 /// from Grey Plane + Palette Color
105 /// ==1 if GetImageDataRaw was used
106 /// ==0 if GetImageData was used
107 /// ==-1 if ImageData never read
110 /// weather already parsed
113 /// To avoid file overwrite
114 std::string OrigFileName;
117 //-----------------------------------------------------------------------------