QXRD  0.11.16
Public Member Functions | Private Member Functions | List of all members
QxrdImageDataFormatHis Class Reference

#include <qxrdimagedataformathis.h>

Inheritance diagram for QxrdImageDataFormatHis:
Inheritance graph
[legend]
Collaboration diagram for QxrdImageDataFormatHis:
Collaboration graph
[legend]

Public Member Functions

 QxrdImageDataFormatHis (QString name="his")
 
QxrdImageDataFormatHiscanLoadFile (QString path)
 
QxrdImageDataFormatHiscanSaveFile (QString path)
 
QxrdImageDataFormatHisloadFile (QString path, QcepImageData< double > *img)
 
QxrdImageDataFormatHissaveFile (QString path, QcepImageData< double > *img, int)
 
Priority priority () const
 
- Public Member Functions inherited from QcepImageDataFormat< double >
 QcepImageDataFormat (QString fmtname)
 
- Public Member Functions inherited from QcepImageDataFormatBase
 QcepImageDataFormatBase (QString name)
 
virtual ~QcepImageDataFormatBase ()
 
QString name () const
 
void setName (QString name)
 
void mkPath (QString filePath)
 
QString uniqueFileName (QString name)
 

Private Member Functions

void checkError (int e)
 

Additional Inherited Members

- Public Types inherited from QcepImageDataFormatBase
enum  Priority { Unable = 0, CatchAll = 1, Versatile = 2, Specific = 3 }
 
enum  { NoOverwrite, CanOverwrite }
 

Detailed Description

Definition at line 8 of file qxrdimagedataformathis.h.

Constructor & Destructor Documentation

QxrdImageDataFormatHis::QxrdImageDataFormatHis ( QString  name = "his")

Member Function Documentation

QxrdImageDataFormatHis * QxrdImageDataFormatHis::canLoadFile ( QString  path)
virtual

Implements QcepImageDataFormat< double >.

Definition at line 38 of file qxrdimagedataformathis.cpp.

References HISHeader::BRX, HISHeader::BRY, checkError(), HISHeader::Correction, HISHeader::FileSize, HISHeader::FileType, HISHeader::HeaderSize, HISHeader::ImageHeaderSize, HISHeader::IntegrationTime, HISHeader::NrOfFrames, HISHeader::TypeOfNumbers, HISHeader::ULX, HISHeader::ULY, and HISHeader::unk.

39 {
40 // printf("QxrdImageDataFormatHis::canLoadFile(%s)\n", qPrintable(path));
41 
42  QxrdImageDataFormatHis* res = NULL;
43 
44  FILE *file = fopen(qPrintable(path), "rb");
45  HISHeader h;
46 
47  if (file) {
48  checkError(fread(&h.FileType, 2, 1, file));
49  checkError(fread(&h.unk, 2, 1, file));
50  checkError(fread(&h.HeaderSize, 2, 1, file));
51  checkError(fread(&h.FileSize, 4, 1, file));
52  checkError(fread(&h.ImageHeaderSize, 2, 1, file));
53  checkError(fread(&h.ULX, 2, 1, file));
54  checkError(fread(&h.ULY, 2, 1, file));
55  checkError(fread(&h.BRX, 2, 1, file));
56  checkError(fread(&h.BRY, 2, 1, file));
57  checkError(fread(&h.NrOfFrames, 2, 1, file));
58  checkError(fread(&h.Correction, 2, 1, file));
59  checkError(fread(&h.IntegrationTime, 8, 1, file));
60  checkError(fread(&h.TypeOfNumbers, 2, 1, file));
61 
62  if (h.FileType == 0x7000 &&
63  h.HeaderSize == 100 &&
64  (h.TypeOfNumbers == 4 || h.TypeOfNumbers == 32)) {
65  res = this;
66  }
67 
68  fclose(file);
69  }
70 
71  return res;
72 }

Here is the call graph for this function:

QxrdImageDataFormatHis * QxrdImageDataFormatHis::canSaveFile ( QString  path)
virtual

Implements QcepImageDataFormat< double >.

Definition at line 74 of file qxrdimagedataformathis.cpp.

75 {
76  return NULL;
77 }
void QxrdImageDataFormatHis::checkError ( int  e)
private

Definition at line 34 of file qxrdimagedataformathis.cpp.

Referenced by canLoadFile(), and loadFile().

35 {
36 }

Here is the caller graph for this function:

QxrdImageDataFormatHis * QxrdImageDataFormatHis::loadFile ( QString  path,
QcepImageData< double > *  img 
)
virtual

Implements QcepImageDataFormat< double >.

Definition at line 79 of file qxrdimagedataformathis.cpp.

References HISHeader::BRX, HISHeader::BRY, checkError(), HISHeader::Correction, HISHeader::FileSize, HISHeader::FileType, HISHeader::HeaderSize, HISHeader::ImageHeaderSize, HISHeader::IntegrationTime, HISHeader::NrOfFrames, HISHeader::TypeOfNumbers, HISHeader::ULX, HISHeader::ULY, and HISHeader::unk.

80 {
81 // printf("QxrdImageDataFormatHis::loadFile(%s)\n", qPrintable(path));
82 
83  FILE *file = fopen(qPrintable(path), "rb");
84 
85  HISHeader h;
86 
87  if (file) {
88  checkError(fread(&h.FileType, 2, 1, file));
89  checkError(fread(&h.unk, 2, 1, file));
90  checkError(fread(&h.HeaderSize, 2, 1, file));
91  checkError(fread(&h.FileSize, 4, 1, file));
92  checkError(fread(&h.ImageHeaderSize, 2, 1, file));
93  checkError(fread(&h.ULX, 2, 1, file));
94  checkError(fread(&h.ULY, 2, 1, file));
95  checkError(fread(&h.BRX, 2, 1, file));
96  checkError(fread(&h.BRY, 2, 1, file));
97  checkError(fread(&h.NrOfFrames, 2, 1, file));
98  checkError(fread(&h.Correction, 2, 1, file));
99  checkError(fread(&h.IntegrationTime, 8, 1, file));
100  checkError(fread(&h.TypeOfNumbers, 2, 1, file));
101 
102  int width = h.BRX-h.ULX+1;
103  int height = h.BRY-h.ULY+1;
104 
105  fseek(file, 100, SEEK_SET);
106 
107  img -> resize(width, height);
108 
109  if (h.TypeOfNumbers == 4) {
110  quint16 pix;
111  for (int y=0; y<height; y++) {
112  for (int x=0; x<width; x++) {
113  checkError(fread(&pix, 2, 1, file));
114  img -> setValue(x,(height-y-1),pix);
115  }
116  }
117  } else if (h.TypeOfNumbers == 32) {
118  quint32 pix;
119  for (int y=0; y<height; y++) {
120  for (int x=0; x<width; x++) {
121  checkError(fread(&pix, 4, 1, file));
122  img -> setValue(x,(height-y-1),pix);
123  }
124  }
125  }
126 
127  fclose(file);
128 
129  img -> calculateRange();
130 
131  img -> setDefaultFileName(path);
132 
133  return this;
134  }
135 
136  return NULL;
137 }

Here is the call graph for this function:

QxrdImageDataFormatHis::Priority QxrdImageDataFormatHis::priority ( ) const
virtual
QxrdImageDataFormatHis * QxrdImageDataFormatHis::saveFile ( QString  path,
QcepImageData< double > *  img,
int   
)
virtual

Implements QcepImageDataFormat< double >.

Definition at line 139 of file qxrdimagedataformathis.cpp.

140 {
141  return NULL;
142 }

The documentation for this class was generated from the following files: