File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
JP2Exporter.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "JP2Exporter.h"
8 
9 #include "Buffer.h"
10 #include "FileName.h"
11 #include "IException.h"
12 #include "IString.h"
13 #include "JP2Encoder.h"
14 
15 using namespace Isis;
16 
17 
18 namespace Isis {
23  m_encoder = NULL;
24  m_buffer = NULL;
25 
26  setExtension("jp2");
27  }
28 
29 
34  delete m_encoder;
35  m_encoder = NULL;
36 
37  delete [] m_buffer;
38  m_buffer = NULL;
39  }
40 
41 
47  PixelType type = pixelType();
48  int mult = (type == Isis::UnsignedByte) ? 1 : 2;
49 
50  m_buffer = new char* [bands()];
51  for (int i = 0; i < bands(); i++)
52  m_buffer[i] = new char[samples() * mult];
53  }
54 
55 
64  void JP2Exporter::write(FileName outputName, int quality,
65  QString compression) {
66 
67  outputName = outputName.addExtension(extension());
68 
69  PixelType type = pixelType();
70  m_encoder = new JP2Encoder(
71  outputName.expanded(), samples(), lines(), bands(), type);
73 
74  ImageExporter::write(outputName, quality);
75  }
76 
77 
85  void JP2Exporter::setBuffer(int s, int b, int dn) const {
86  PixelType type = pixelType();
87  switch (type) {
88  case UnsignedByte:
89  ((unsigned char *) m_buffer[b])[s] = (unsigned char) dn;
90  break;
91  case SignedWord:
92  ((short int *) m_buffer[b])[s] = (short int) dn;
93  break;
94  case UnsignedWord:
95  ((short unsigned int *) m_buffer[b])[s] = (short unsigned int) dn;
96  break;
97  default:
99  "Invalid pixel type for data [" + toString(type) + "]",
100  _FILEINFO_);
101  }
102  }
103 
104 
110  void JP2Exporter::writeLine(int l) const {
111  PixelType type = pixelType();
112  if (type == Isis::UnsignedByte)
113  m_encoder->Write((unsigned char **) m_buffer);
114  else
115  m_encoder->Write((short int **) m_buffer);
116  }
117 
118 
126  bool JP2Exporter::canWriteFormat(QString format) {
127  return format == "jp2";
128  }
129 };
130 
Isis::JP2Exporter::JP2Exporter
JP2Exporter()
Construct the JPEG 2000 exporter.
Definition: JP2Exporter.cpp:22
Isis::JP2Exporter::m_buffer
char ** m_buffer
Two dimensional array containing all color channels for a line.
Definition: JP2Exporter.h:55
Isis::JP2Exporter::setBuffer
virtual void setBuffer(int s, int b, int dn) const
Set the DN value at the given sample and band of the line buffer.
Definition: JP2Exporter.cpp:85
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::JP2Encoder::OpenFile
void OpenFile()
Open the JPEG2000 file and initialize it.
Definition: JP2Encoder.cpp:108
Isis::JP2Exporter::m_encoder
JP2Encoder * m_encoder
Object responsible for writing data to the output image.
Definition: JP2Exporter.h:52
Isis::JP2Exporter::createBuffer
virtual void createBuffer()
Creates the buffer to store a chunk of streamed line data with one or more bands.
Definition: JP2Exporter.cpp:46
Isis::JP2Exporter::writeLine
virtual void writeLine(int l) const
Writes a line of buffered data to the output image on disk.
Definition: JP2Exporter.cpp:110
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::StreamExporter
Exports cubes into a standard format in incremental pieces.
Definition: StreamExporter.h:34
Isis::ImageExporter::write
virtual void write(FileName outputName, int quality=100, QString compression="none")
Export the Isis cube channels to the given standard image.
Definition: ImageExporter.cpp:101
Isis::FileName::expanded
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:196
Isis::FileName::addExtension
FileName addExtension(const QString &extension) const
Adds a new extension to the file name.
Definition: FileName.cpp:225
Isis::JP2Exporter::~JP2Exporter
virtual ~JP2Exporter()
Destruct the exporter.
Definition: JP2Exporter.cpp:33
Isis::ImageExporter::extension
QString extension() const
Gets the extension for the output image.
Definition: ImageExporter.cpp:208
Isis::JP2Encoder
JPEG2000 encoder class.
Definition: JP2Encoder.h:67
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::PixelType
PixelType
Enumerations for Isis Pixel Types.
Definition: PixelType.h:27
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
Isis::ImageExporter::lines
int lines() const
Number of lines (rows) in the output image.
Definition: ImageExporter.cpp:128
Isis::JP2Encoder::Write
void Write(unsigned char **inbuf)
Write 8-bit data to JP2 file.
Definition: JP2Encoder.cpp:260
Isis::ImageExporter::bands
int bands() const
Number of bands (channels) in the output image.
Definition: ImageExporter.cpp:138
Isis::JP2Exporter::canWriteFormat
static bool canWriteFormat(QString format)
Returns true if the format is "jp2".
Definition: JP2Exporter.cpp:126
Isis::ImageExporter::pixelType
PixelType pixelType() const
Returns the pixel type.
Definition: ImageExporter.cpp:307
Isis::JP2Exporter::write
virtual void write(FileName outputName, int quality=100, QString compression="none")
Initialize the encoder, open the output file for writing, then let the base ImageExporter handle the ...
Definition: JP2Exporter.cpp:64
Isis::ImageExporter::samples
int samples() const
Number of samples (columns) in the output image.
Definition: ImageExporter.cpp:118
Isis::ImageExporter::setExtension
void setExtension(QString extension)
Sets the extension for the output image and generates the extension for the world file from it.
Definition: ImageExporter.cpp:193
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:16:44