]> Creatis software - gdcm.git/blob - src/gdcmFile.h
9fc32baed090dbfc5dfb690aa5d77036b44a932f
[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      
39 protected:
40    int WriteBase(std::string FileName, FileType type);
41
42 public:
43    gdcmFile(gdcmHeader *header);
44    gdcmFile(std::string & filename);
45    gdcmFile(const char * filename);
46    virtual ~gdcmFile(void);
47         
48    gdcmHeader *GetHeader(void);
49
50         // For promotion (performs a deepcopy of pointed header object)
51         // TODO Swig gdcmFile(gdcmHeader* header);
52         // TODO Swig ~gdcmFile();
53
54         // On writing purposes. When instance was created through
55         // gdcmFile(std::string filename) then the filename argument MUST be
56         // different from the constructor's one (no overwriting allowed).
57         // TODO Swig int SetFileName(std::string filename);
58
59    void   SetPixelDataSizeFromHeader(void);
60    size_t GetImageDataSize();
61    size_t GetImageDataSizeRaw();
62    void * GetImageData();
63    size_t GetImageDataIntoVector(void* destination, size_t MaxSize);
64    void * GetImageDataRaw();
65    size_t GetImageDataIntoVectorRaw(void* destination, size_t MaxSize);
66         
67       // Allocates ExpectedSize bytes of memory at this->Data and copies the
68       // pointed data to it. Copying the image might look useless but
69       // the caller might destroy it's image (without knowing it: think
70       // of a complicated interface where display is done with a library
71       // e.g. VTK) before calling the Write
72    int SetImageData     (void * Data, size_t ExpectedSize);
73       // When the caller is aware we simply point to the data:
74       // TODO int SetImageDataNoCopy (void * Data, size_t ExpectedSize);
75         
76         // Push to disk.
77         // A NE PAS OUBLIER : que fait-on en cas de Transfert Syntax (dans l'entete)
78         // incohérente avec l'ordre des octets en mémoire ? 
79         // TODO Swig int Write();
80         
81         // Ecrit sur disque les pixels d'UNE image
82         // Aucun test n'est fait sur l'"Endiannerie" du processeur.
83         // Ca sera à l'utilisateur d'appeler son Reader correctement
84                 
85    int WriteRawData  (std::string fileName);
86    int WriteDcmImplVR(std::string fileName);
87    int WriteDcmImplVR(const char * fileName);
88    int WriteDcmExplVR(std::string fileName);
89    int WriteAcr      (std::string fileName);
90    
91    bool ParsePixelData(void);
92 };
93
94 #endif