]> Creatis software - gdcm.git/blob - src/gdcmFile.h
remove H Table NameHT
[gdcm.git] / src / gdcmFile.h
1 // gdcmFile.h
2
3 #ifndef GDCMFILE_H
4 #define GDCMFILE_H
5
6 #include "gdcmCommon.h"
7 #include "gdcmHeader.h"
8
9 /*
10  * In addition to Dicom header exploration, this class is designed
11  * for accessing the image/volume content. One can also use it to
12  * write Dicom files.
13  */
14 class GDCM_EXPORT gdcmFile
15 {
16 private:
17    gdcmHeader *Header;   // Header to use to load the file
18    bool SelfHeader;
19
20    void* PixelData;
21    size_t lgrTotaleRaw;  // Area length to receive the pixels
22    size_t lgrTotale;     // Area length to receive the RGB pixels
23                          // from Grey Plane + Palette Color
24
25    int Parsed;               // weather already parsed
26    std::string OrigFileName; // To avoid file overwrite
27    void SwapZone(void* im, int swap, int lgr, int nb);
28    
29    bool ReadPixelData(void * destination);
30    
31    bool gdcm_read_JPEG_file     (FILE *fp,void * image_buffer); // For JPEG 8 Bits
32    bool gdcm_read_JPEG_file12   (FILE *fp,void * image_buffer); // For JPEG 12 Bits
33    bool gdcm_read_JPEG2000_file (FILE *fp,void * image_buffer); // For JPEG 2000 (TODO)
34
35 // For Run Length Encoding (TOCHECK)
36    bool gdcm_read_RLE_file      (FILE *fp,void * image_buffer); 
37
38 protected:
39    bool WriteBase(std::string FileName, FileType type);
40
41 public:
42    gdcmFile(gdcmHeader *header);
43    gdcmFile(std::string & filename);
44    gdcmFile(const char * filename);
45    virtual ~gdcmFile(void);
46         
47    gdcmHeader *GetHeader(void);
48
49         // For promotion (performs a deepcopy of pointed header object)
50         // TODO Swig gdcmFile(gdcmHeader* header);
51         // TODO Swig ~gdcmFile();
52
53         // On writing purposes. When instance was created through
54         // gdcmFile(std::string filename) then the filename argument MUST be
55         // different from the constructor's one (no overwriting allowed).
56         // TODO Swig int SetFileName(std::string filename);
57
58    void   SetPixelDataSizeFromHeader(void);
59    size_t GetImageDataSize();
60    size_t GetImageDataSizeRaw();
61    void * GetImageData();
62    size_t GetImageDataIntoVector(void* destination, size_t MaxSize);
63    void * GetImageDataRaw();
64    size_t GetImageDataIntoVectorRaw(void* destination, size_t MaxSize);
65         
66       // Allocates ExpectedSize bytes of memory at this->Data and copies the
67       // pointed data to it. Copying the image might look useless but
68       // the caller might destroy it's image (without knowing it: think
69       // of a complicated interface where display is done with a library
70       // e.g. VTK) before calling the Write
71       
72    // voir gdcmHeader::SetImageDataSize ?!?         
73    bool SetImageData     (void * Data, size_t ExpectedSize);
74       // When the caller is aware we simply point to the data:
75       // TODO int SetImageDataNoCopy (void * Data, size_t ExpectedSize);
76         
77         // Push to disk.
78         // A NE PAS OUBLIER : que fait-on en cas de Transfert Syntax (dans l'entete)
79         // incohérente avec l'ordre des octets en mémoire ? 
80         // TODO Swig int Write();
81         
82         // Ecrit sur disque les pixels d'UNE image
83         // Aucun test n'est fait sur l'"Endiannerie" du processeur.
84         // Ca sera à l'utilisateur d'appeler son Reader correctement
85                 
86    bool WriteRawData  (std::string fileName);
87    bool WriteDcmImplVR(std::string fileName);
88    bool WriteDcmImplVR(const char * fileName);
89    bool WriteDcmExplVR(std::string fileName);
90    bool WriteAcr      (std::string fileName);
91    
92    bool ParsePixelData(void);
93 };
94
95 #endif