10#include <QImageWriter> 
   13#include "ExportDescription.h" 
   15#include "IException.h" 
   17#include "UserInterface.h" 
   35    else if (format == 
"jpeg")
 
   37    else if (format == 
"tiff")
 
   39    else if (format == 
"gif")
 
   41    else if (format == 
"bmp")
 
 
   62    if (desc.pixelType() != UnsignedByte) {
 
   63      QString msg = 
"Invalid pixel type. The Qt exporter for file type [";
 
   65      msg += 
"] requires an unsigned byte (i.e. 8BIT) output.";
 
 
   86    for (
int i = 0; i < 256; i++) {
 
   87      colors.push_back(qRgb(i, i, i));
 
 
  127    Buffer &grayLine = *in[0];
 
  131    int lineIndex = grayLine.
Line() - 1;
 
  132    for (
int sampleIndex = 0; sampleIndex < grayLine.SampleDimension(); sampleIndex++) {
 
  137      m_qimage->setPixel(sampleIndex, lineIndex, pixelValue);
 
  138      if (!
m_qimage->valid(sampleIndex, lineIndex)) {
 
  139        QString msg = 
"Qt has detected your file size as exceeding 2GB.";
 
  140        msg += 
" While your image might be under 2GB, your image labels are more";
 
  141        msg += 
" than likely pushing the file size over 2GB.";
 
 
  155    Buffer &greenLine = *in[1];
 
  156    Buffer &blueLine = *in[2];
 
  158    QRgb *line = (QRgb *) 
m_qimage->scanLine(redLine.Line() - 1);
 
  159    for (
int s = 0; s < redLine.SampleDimension(); s++) {
 
  164      line[s] = qRgb(red, green, blue);
 
 
  176    Buffer &greenLine = *in[1];
 
  177    Buffer &blueLine = *in[2];
 
  178    Buffer &alphaLine = *in[3];
 
  180    QRgb *line = (QRgb *) 
m_qimage->scanLine(redLine.Line() - 1);
 
  181    for (
int s = 0; s < redLine.SampleDimension(); s++) {
 
  187      line[s] = qRgba(red, green, blue, alpha);
 
 
  204    outputName = outputName.addExtension(
extension());
 
  211      QString err = 
"Unable to save [" + outputName.expanded() +
 
 
  231    if (size >= maxSize) {
 
  232      QString gigaBytes = 
toString(size / (1024.0 * 1024.0 * 1024.0));
 
  233      QString msg = 
"Cube exceeds max size of 2GB. Qimage cannot support ";
 
  234      msg += 
"that much raw data. Your cube is " + gigaBytes + 
" GB.";
 
 
  248    bool supported = 
false;
 
  249    QList<QByteArray> list = QImageWriter::supportedImageFormats();
 
  251    while (it != list.end() && !supported) {
 
  252      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.
 
Describes how a series of cubes should be exported.
 
File name manipulation and expansion.
 
@ Unknown
A type of error that cannot be classified as any of the other error types.
 
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
 
@ Programmer
This error is for when a programmer made an API call that was illegal.
 
Export Isis cubes into standard formats.
 
int lines() const
Number of lines (rows) in the output image.
 
QString extension() const
Gets the extension for the output image.
 
int bands() const
Number of bands (channels) in the output image.
 
virtual void write(FileName outputName, int quality=100, QString compression="none", UserInterface *ui=nullptr)
Export the Isis cube channels to the given standard image.
 
int samples() const
Number of samples (columns) in the output image.
 
virtual void initialize(ExportDescription &desc)=0
Generic initialization with the export description.
 
void setExtension(QString extension)
Sets the extension for the output image and generates the extension for the world file from it.
 
virtual int outputPixelValue(double dn) const
Return the output clamped integer pixel value from the input double-precision DN.
 
virtual void setGrayscale(ExportDescription &desc)
Set the input with the description generically, check the data size for a single-band image with the ...
 
QString m_format
The lowercase abbreviated format of the output image.
 
virtual void setRgb(ExportDescription &desc)
Set the input with the description generically, check the data size for a three-band image with the e...
 
virtual void write(FileName outputName, int quality=100, QString compression="none", UserInterface *ui=nullptr)
Let the base ImageExporter handle the generic black-box writing routine, then save the image to disk.
 
virtual void writeRgba(vector< Buffer * > &in) const
Write a line of RGBA data to the output image.
 
QtExporter(QString format)
Construct the Qt exporter.
 
virtual void writeGrayscale(vector< Buffer * > &in) const
Write a line of grayscale data to the output image.
 
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.
 
static bool canWriteFormat(QString format)
Returns true if the format is supported by QImageWriter.
 
void initialize(ExportDescription &desc)
Generic initialization with the export description.
 
QImage * m_qimage
Structure holding all output image data in memory.
 
virtual void writeRgb(vector< Buffer * > &in) const
Write a line of RGB data to 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 ~QtExporter()
Destruct the exporter.
 
Command Line and Xml loader, validation, and access.
 
This is free and unencumbered software released into the public domain.
 
This is free and unencumbered software released into the public domain.
 
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
 
long long int BigInt
Big int.