]> Creatis software - gdcm.git/blob - src/gdcmFile.h
* src/*.h : add comments
[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    int 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    int SetImageData     (void * Data, size_t ExpectedSize);
72       // When the caller is aware we simply point to the data:
73       // TODO int SetImageDataNoCopy (void * Data, size_t ExpectedSize);
74         
75         // Push to disk.
76         // A NE PAS OUBLIER : que fait-on en cas de Transfert Syntax (dans l'entete)
77         // incohérente avec l'ordre des octets en mémoire ? 
78         // TODO Swig int Write();
79         
80         // Ecrit sur disque les pixels d'UNE image
81         // Aucun test n'est fait sur l'"Endiannerie" du processeur.
82         // Ca sera à l'utilisateur d'appeler son Reader correctement
83    int WriteRawData  (std::string fileName);
84    int WriteDcmImplVR(std::string fileName);
85    int WriteDcmImplVR(const char * fileName);
86    int WriteDcmExplVR(std::string fileName);
87    int WriteAcr      (std::string fileName);
88    
89    bool ParsePixelData(void);
90 };
91
92 #endif