Isis 3 Programmer Reference
StreamExporter.cpp
1 #include "StreamExporter.h"
2 
3 #include "Buffer.h"
4 #include "ExportDescription.h"
5 #include "ProcessExport.h"
6 
7 using namespace Isis;
8 using namespace std;
9 
10 
11 namespace Isis {
16  }
17 
18 
23  }
24 
25 
34  initialize(desc);
35  }
36 
37 
46  initialize(desc);
47  }
48 
49 
58  initialize(desc);
59  }
60 
61 
70  createBuffer();
71  }
72 
73 
79  void StreamExporter::writeGrayscale(vector<Buffer *> &in) const {
80  Buffer &grayLine = *in[0];
81 
82  int lineIndex = grayLine.Line() - 1;
83  for (int sampleIndex = 0; sampleIndex < grayLine.SampleDimension(); sampleIndex++) {
84  int pixelValue = outputPixelValue(grayLine[sampleIndex]);
85  setBuffer(sampleIndex, 0, pixelValue);
86  }
87 
88  writeLine(lineIndex);
89  }
90 
91 
97  void StreamExporter::writeRgb(vector<Buffer *> &in) const {
98  Buffer &redLine = *in[0];
99  Buffer &greenLine = *in[1];
100  Buffer &blueLine = *in[2];
101 
102  for (int i = 0; i < redLine.SampleDimension(); i++) {
103  int red = outputPixelValue(redLine[i]);
104  int green = outputPixelValue(greenLine[i]);
105  int blue = outputPixelValue(blueLine[i]);
106 
107  setBuffer(i, 0, red);
108  setBuffer(i, 1, green);
109  setBuffer(i, 2, blue);
110  }
111 
112  writeLine(redLine.Line() - 1);
113  }
114 
115 
121  void StreamExporter::writeRgba(vector<Buffer *> &in) const {
122  Buffer &redLine = *in[0];
123  Buffer &greenLine = *in[1];
124  Buffer &blueLine = *in[2];
125  Buffer &alphaLine = *in[3];
126 
127  for (int i = 0; i < redLine.SampleDimension(); i++) {
128  int red = outputPixelValue(redLine[i]);
129  int green = outputPixelValue(greenLine[i]);
130  int blue = outputPixelValue(blueLine[i]);
131  int alpha = outputPixelValue(alphaLine[i]);
132 
133  setBuffer(i, 0, red);
134  setBuffer(i, 1, green);
135  setBuffer(i, 2, blue);
136  setBuffer(i, 3, alpha);
137  }
138 
139  writeLine(redLine.Line() - 1);
140  }
141 };
142 
Buffer for reading and writing cube data.
Definition: Buffer.h:69
StreamExporter()
Construct the stream exporter.
virtual void setGrayscale(ExportDescription &desc)
Generic initialization with the export description.
virtual void initialize(ExportDescription &desc)
Generic initialization with the export description.
Export Isis cubes into standard formats.
Definition: ImageExporter.h:70
virtual int outputPixelValue(double dn) const
Return the output clamped integer pixel value from the input double-precision DN. ...
Namespace for the standard library.
virtual void createBuffer()=0
Pure virtual method for creating the buffer to store a chunk of streamed line data with one or more b...
virtual void writeRgb(vector< Buffer *> &in) const
Write a line of RGB data to the output image.
virtual void setBuffer(int s, int b, int dn) const =0
Pure virtual method for setting a particular index of the line buffer to the given DN...
virtual ~StreamExporter()
Destruct the exporter.
int Line(const int index=0) const
Returns the line position associated with a shape buffer index.
Definition: Buffer.cpp:161
Describes how a series of cubes should be exported.
virtual void initialize(ExportDescription &desc)=0
Generic initialization with the export description.
virtual void writeLine(int l) const =0
Pure virtual method for writing a line of buffered data to the output image on disk.
int SampleDimension() const
Returns the number of samples in the shape buffer.
Definition: Buffer.h:86
virtual void setRgb(ExportDescription &desc)
Generic initialization with the export description.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
virtual void writeRgba(vector< Buffer *> &in) const
Write a line of RGBA data to the output image.
virtual void setRgba(ExportDescription &desc)
Generic initialization with the export description.
virtual void writeGrayscale(vector< Buffer *> &in) const
Write a line of grayscale data to the output image.