4 #include <QImageWriter>
28 else if (format ==
"jpeg")
30 else if (format ==
"tiff")
32 else if (format ==
"gif")
34 else if (format ==
"bmp")
56 QString msg =
"Invalid pixel type. The Qt exporter for file type [";
58 msg +=
"] requires an unsigned byte (i.e. 8BIT) output.";
79 for (
int i = 0; i < 256; i++) {
80 colors.push_back(qRgb(i, i, i));
120 Buffer &grayLine = *in[0];
124 int lineIndex = grayLine.
Line() - 1;
125 for (
int sampleIndex = 0; sampleIndex < grayLine.
SampleDimension(); sampleIndex++) {
130 m_qimage->setPixel(sampleIndex, lineIndex, pixelValue);
131 if (!
m_qimage->valid(sampleIndex, lineIndex)) {
132 QString msg =
"Qt has detected your file size as exceeding 2GB.";
133 msg +=
" While your image might be under 2GB, your image labels are more";
134 msg +=
" than likely pushing the file size over 2GB.";
148 Buffer &greenLine = *in[1];
149 Buffer &blueLine = *in[2];
151 QRgb *line = (QRgb *)
m_qimage->scanLine(redLine.
Line() - 1);
157 line[s] = qRgb(red, green, blue);
169 Buffer &greenLine = *in[1];
170 Buffer &blueLine = *in[2];
171 Buffer &alphaLine = *in[3];
173 QRgb *line = (QRgb *)
m_qimage->scanLine(redLine.
Line() - 1);
180 line[s] = qRgba(red, green, blue, alpha);
194 QString compression) {
197 outputName = outputName.addExtension(
extension());
204 QString err =
"Unable to save [" + outputName.expanded() +
221 BigInt maxSize = (BigInt) 2 * 1024 * 1024 * 1024;
223 BigInt size = samples * lines *
bands;
224 if (size >= maxSize) {
225 QString gigaBytes =
toString(size / (1024.0 * 1024.0 * 1024.0));
226 QString msg =
"Cube exceeds max size of 2GB. Qimage cannot support ";
227 msg +=
"that much raw data. Your cube is " + gigaBytes +
" GB.";
241 bool supported =
false;
244 while (it != list.end() && !supported) {
245 if (*it == QString(format)) supported =
true;
Buffer for reading and writing cube data.
int Line(const int index=0) const
Returns the line position associated with a shape buffer index.
void checkDataSize(BigInt samples, BigInt lines, int bands)
Checks that the data size for an image of the desired dimensions will be less than 2GB...
int samples() const
Number of samples (columns) in the output image.
File name manipulation and expansion.
PixelType pixelType() const
Returns the pixel type.
Export Isis cubes into standard formats.
virtual void writeGrayscale(vector< Buffer * > &in) const
Write a line of grayscale data to the output image.
virtual void writeRgb(vector< Buffer * > &in) const
Write a line of RGB data to the output image.
virtual int outputPixelValue(double dn) const
Return the output clamped integer pixel value from the input double-precision DN. ...
virtual ~QtExporter()
Destruct the exporter.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
This error is for when a programmer made an API call that was illegal.
void setExtension(QString extension)
Sets the extension for the output image and generates the extension for the world file from it...
int bands() const
Number of bands (channels) in the output image.
QImage * m_qimage
Structure holding all output image data in memory.
virtual void write(FileName outputName, int quality=100, QString compression="none")
Let the base ImageExporter handle the generic black-box writing routine, then save the image to disk...
int lines() const
Number of lines (rows) in the output image.
QString extension() const
Gets the extension for the output image.
virtual void setRgba(ExportDescription &desc)
Set the input with the description generically, check the data size for a four-band image with the es...
virtual void setRgb(ExportDescription &desc)
Set the input with the description generically, check the data size for a three-band image with the e...
QtExporter(QString format)
Construct the Qt exporter.
#define _FILEINFO_
Macro for the filename and line number.
A type of error that could only have occurred due to a mistake on the user's part (e...
virtual void setGrayscale(ExportDescription &desc)
Set the input with the description generically, check the data size for a single-band image with the ...
A type of error that cannot be classified as any of the other error types.
static bool canWriteFormat(QString format)
Returns true if the format is supported by QImageWriter.
Describes how a series of cubes should be exported.
virtual void initialize(ExportDescription &desc)=0
Generic initialization with the export description.
QString m_format
The lowercase abbreviated format of the output image.
virtual void write(FileName outputName, int quality=100, QString compression="none")
Export the Isis cube channels to the given standard image.
virtual void writeRgba(vector< Buffer * > &in) const
Write a line of RGBA data to the output image.
void initialize(ExportDescription &desc)
Generic initialization with the export description.
int SampleDimension() const
Returns the number of samples in the shape buffer.