]> Creatis software - gdcm.git/blob - src/gdcmFile.h
Add JPEG 6b files
[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: public gdcmHeader
15 {
16 private:
17    void* PixelData;
18    size_t lgrTotale;
19    int Parsed;               // weather allready parsed
20    std::string OrigFileName; // To avoid file overwrite
21    void SwapZone(void* im, int swap, int lgr, int nb);
22    bool ReadPixelData(void * destination);
23    
24    int gdcm_read_JPEG_file (void * image_buffer);   
25   
26 protected:
27    int WriteBase(std::string FileName, FileType type);
28 public:
29    gdcmFile(std::string & filename);
30    gdcmFile(const char * filename);
31         
32         // For promotion (performs a deepcopy of pointed header object)
33         // TODO Swig gdcmFile(gdcmHeader* header);
34         // TODO Swig ~gdcmFile();
35
36         // On writing purposes. When instance was created through
37         // gdcmFile(std::string filename) then the filename argument MUST be
38         // different from the constructor's one (no overwriting allowed).
39         // TODO Swig int SetFileName(std::string filename);
40
41    void   SetPixelDataSizeFromHeader(void);
42    size_t GetImageDataSize();
43    void * GetImageData();
44    size_t GetImageDataIntoVector(void* destination, size_t MaxSize );
45         
46       // Allocates ExpectedSize bytes of memory at this->Data and copies the
47       // pointed data to it. Copying the image might look useless but
48       // the caller might destroy it's image (without knowing it: think
49       // of a complicated interface where display is done with a library
50       // e.g. VTK) before calling the Write
51    int SetImageData     (void * Data, size_t ExpectedSize);
52       // When the caller is aware we simply point to the data:
53       // TODO int SetImageDataNoCopy (void * Data, size_t ExpectedSize);
54    void SetImageDataSize (size_t ExpectedSize);
55         
56         // Push to disk.
57         // A NE PAS OUBLIER : que fait-on en cas de Transfert Syntax (dans l'entete)
58         // incohérente avec l'ordre des octets en mémoire ? 
59         // TODO Swig int Write();
60         
61         // Ecrit sur disque les pixels d'UNE image
62         // Aucun test n'est fait sur l'"Endiannerie" du processeur.
63         // Ca sera à l'utilisateur d'appeler son Reader correctement
64                 
65    int WriteRawData  (std::string nomFichier);
66    int WriteDcmImplVR(std::string nomFichier);
67    int WriteDcmImplVR(const char * nomFichier);
68    int WriteDcmExplVR(std::string nomFichier);
69    int WriteAcr      (std::string nomFichier);
70 };
71
72 #endif