Isis 3 Programmer Reference
QtImporter.cpp
1 #include "QtImporter.h"
2 
3 #include <QImage>
4 
5 #include "FileName.h"
6 #include "IException.h"
7 #include "IString.h"
8 
9 using namespace Isis;
10 
11 
12 namespace Isis {
18  QtImporter::QtImporter(FileName inputName) : ImageImporter(inputName) {
19  m_qimage = NULL;
20 
21  m_qimage = new QImage(inputName.expanded());
22  if (m_qimage->isNull()) {
24  "The file [" + inputName.expanded() +
25  "] does not contain a recognized image format",
26  _FILEINFO_);
27  }
28 
29  setSamples(m_qimage->width());
30  setLines(m_qimage->height());
32  }
33 
34 
39  delete m_qimage;
40  m_qimage = NULL;
41  }
42 
43 
49  bool QtImporter::isGrayscale() const {
50  return m_qimage->isGrayscale();
51  }
52 
53 
60  bool QtImporter::isRgb() const {
61  return !isGrayscale() && !isArgb();
62  }
63 
64 
70  bool QtImporter::isArgb() const {
71  return m_qimage->hasAlphaChannel();
72  }
73 
74 
82  void QtImporter::updateRawBuffer(int line, int band) const {
83  }
84 
85 
96  int QtImporter::getPixel(int s, int l) const {
97  return m_qimage->pixel(s, l);
98  }
99 
100 
108  int QtImporter::getGray(int pixel) const {
109  return qGray(pixel);
110  }
111 
112 
120  int QtImporter::getRed(int pixel) const {
121  return qRed(pixel);
122  }
123 
124 
132  int QtImporter::getGreen(int pixel) const {
133  return qGreen(pixel);
134  }
135 
136 
144  int QtImporter::getBlue(int pixel) const {
145  return qBlue(pixel);
146  }
147 
148 
156  int QtImporter::getAlpha(int pixel) const {
157  return qAlpha(pixel);
158  }
159 };
160 
QImage * m_qimage
Structure holding all input image data in memory.
Definition: QtImporter.h:76
File name manipulation and expansion.
Definition: FileName.h:116
virtual int getBlue(int pixel) const
Retrieves the blue component of the given pixel.
Definition: QtImporter.cpp:144
void setDefaultBands()
Set the number of bands to be created for the output cube based on the number of color channels in th...
virtual void updateRawBuffer(int line, int band) const
Does nothing as Qt reads the entire input image into memory, and therefore does not need to be update...
Definition: QtImporter.cpp:82
virtual int getGray(int pixel) const
Retrieves the gray component of the given pixel.
Definition: QtImporter.cpp:108
virtual int getAlpha(int pixel) const
Retrieves the alpha component of the given pixel.
Definition: QtImporter.cpp:156
virtual bool isArgb() const
Tests to see if the input image is has an alpha channel, implying RGBA.
Definition: QtImporter.cpp:70
virtual bool isRgb() const
Tests to see if the input image is neither grayscale nor has an alpha channel, implying RGB (no alpha...
Definition: QtImporter.cpp:60
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
void setSamples(int s)
Set the sample dimension (width) of the output image.
A type of error that could only have occurred due to a mistake on the user&#39;s part (e...
Definition: IException.h:142
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:212
void setLines(int l)
Set the line dimension (height) of the output image.
QtImporter(FileName inputName)
Construct the importer.
Definition: QtImporter.cpp:18
virtual int getRed(int pixel) const
Retrieves the red component of the given pixel.
Definition: QtImporter.cpp:120
virtual ~QtImporter()
Destruct the importer.
Definition: QtImporter.cpp:38
virtual bool isGrayscale() const
Tests to see if the input image is grayscale (no RGB/A).
Definition: QtImporter.cpp:49
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Imports images with standard formats into Isis as cubes.
Definition: ImageImporter.h:55
virtual int getPixel(int s, int l) const
Returns a representation of a pixel for the input format that can then be broken down into specific g...
Definition: QtImporter.cpp:96
virtual int getGreen(int pixel) const
Retrieves the green component of the given pixel.
Definition: QtImporter.cpp:132