Isis 3 Programmer Reference
StreamExporter.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "StreamExporter.h"
8
9#include "Buffer.h"
10#include "ExportDescription.h"
11#include "ProcessExport.h"
12
13using namespace Isis;
14using namespace std;
15
16
17namespace Isis {
23
24
30
31
42
43
54
55
66
67
78
79
85 void StreamExporter::writeGrayscale(vector<Buffer *> &in) const {
86 Buffer &grayLine = *in[0];
87
88 int lineIndex = grayLine.Line() - 1;
89 for (int sampleIndex = 0; sampleIndex < grayLine.SampleDimension(); sampleIndex++) {
90 int pixelValue = outputPixelValue(grayLine[sampleIndex]);
91 setBuffer(sampleIndex, 0, pixelValue);
92 }
93
94 writeLine(lineIndex);
95 }
96
97
103 void StreamExporter::writeRgb(vector<Buffer *> &in) const {
104 Buffer &redLine = *in[0];
105 Buffer &greenLine = *in[1];
106 Buffer &blueLine = *in[2];
107
108 for (int i = 0; i < redLine.SampleDimension(); i++) {
109 int red = outputPixelValue(redLine[i]);
110 int green = outputPixelValue(greenLine[i]);
111 int blue = outputPixelValue(blueLine[i]);
112
113 setBuffer(i, 0, red);
114 setBuffer(i, 1, green);
115 setBuffer(i, 2, blue);
116 }
117
118 writeLine(redLine.Line() - 1);
119 }
120
121
127 void StreamExporter::writeRgba(vector<Buffer *> &in) const {
128 Buffer &redLine = *in[0];
129 Buffer &greenLine = *in[1];
130 Buffer &blueLine = *in[2];
131 Buffer &alphaLine = *in[3];
132
133 for (int i = 0; i < redLine.SampleDimension(); i++) {
134 int red = outputPixelValue(redLine[i]);
135 int green = outputPixelValue(greenLine[i]);
136 int blue = outputPixelValue(blueLine[i]);
137 int alpha = outputPixelValue(alphaLine[i]);
138
139 setBuffer(i, 0, red);
140 setBuffer(i, 1, green);
141 setBuffer(i, 2, blue);
142 setBuffer(i, 3, alpha);
143 }
144
145 writeLine(redLine.Line() - 1);
146 }
147};
148
Buffer for reading and writing cube data.
Definition Buffer.h:53
int Line(const int index=0) const
Returns the line position associated with a shape buffer index.
Definition Buffer.cpp:145
Describes how a series of cubes should be exported.
Export Isis cubes into standard formats.
virtual void initialize(ExportDescription &desc)=0
Generic initialization with the export description.
virtual int outputPixelValue(double dn) const
Return the output clamped integer pixel value from the input double-precision DN.
virtual void writeLine(int l) const =0
Pure virtual method for writing a line of buffered data to the output image on disk.
virtual void writeRgba(vector< Buffer * > &in) const
Write a line of RGBA data to the output image.
virtual void setGrayscale(ExportDescription &desc)
Generic initialization with the export description.
virtual ~StreamExporter()
Destruct the exporter.
virtual void setRgba(ExportDescription &desc)
Generic initialization with the export description.
StreamExporter()
Construct the stream exporter.
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 void initialize(ExportDescription &desc)
Generic initialization with the export description.
virtual void setRgb(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.
virtual void createBuffer()=0
Pure virtual method for creating the buffer to store a chunk of streamed line data with one or more b...
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.