|
Isis 3.0 Object Programmers' Reference |
Home |
00001 #include "StreamExporter.h" 00002 00003 #include "Buffer.h" 00004 #include "ExportDescription.h" 00005 #include "ProcessExport.h" 00006 00007 using namespace Isis; 00008 00009 00010 namespace Isis { 00014 StreamExporter::StreamExporter() : ImageExporter() { 00015 m_type = Isis::None; 00016 } 00017 00018 00022 StreamExporter::~StreamExporter() { 00023 } 00024 00025 00033 void StreamExporter::setGrayscale(ExportDescription &desc) { 00034 initialize(desc); 00035 } 00036 00037 00045 void StreamExporter::setRgb(ExportDescription &desc) { 00046 initialize(desc); 00047 } 00048 00049 00057 void StreamExporter::setRgba(ExportDescription &desc) { 00058 initialize(desc); 00059 } 00060 00061 00068 void StreamExporter::initialize(ExportDescription &desc) { 00069 setInput(desc); 00070 setType(desc); 00071 } 00072 00073 00079 void StreamExporter::setType(ExportDescription &desc) { 00080 ProcessExport &p = getProcess(); 00081 p.SetFormat(ProcessExport::BIL); 00082 00083 m_type = desc.getPixelType(); 00084 createBuffer(); 00085 00086 p.SetOutputType(desc.getPixelType()); 00087 p.SetOutputNull(desc.getOutputNull()); 00088 p.SetOutputRange(desc.getOutputMinimum(), desc.getOutputMaximum()); 00089 00090 setOutputRange(desc.getOutputMinimum(), desc.getOutputMaximum()); 00091 } 00092 00093 00099 PixelType StreamExporter::getPixelType() const { 00100 return m_type; 00101 } 00102 00103 00109 void StreamExporter::writeGrayscale(vector<Buffer *> &in) const { 00110 Buffer &grayLine = *in[0]; 00111 00112 for (int i = 0; i < grayLine.SampleDimension(); i++) { 00113 int dn = getPixel(grayLine[i]); 00114 setBuffer(i, 0, dn); 00115 } 00116 00117 writeLine(grayLine.Line() - 1); 00118 } 00119 00120 00126 void StreamExporter::writeRgb(vector<Buffer *> &in) const { 00127 Buffer &redLine = *in[0]; 00128 Buffer &greenLine = *in[1]; 00129 Buffer &blueLine = *in[2]; 00130 00131 for (int i = 0; i < redLine.SampleDimension(); i++) { 00132 int red = getPixel(redLine[i]); 00133 int green = getPixel(greenLine[i]); 00134 int blue = getPixel(blueLine[i]); 00135 00136 setBuffer(i, 0, red); 00137 setBuffer(i, 1, green); 00138 setBuffer(i, 2, blue); 00139 } 00140 00141 writeLine(redLine.Line() - 1); 00142 } 00143 00144 00150 void StreamExporter::writeRgba(vector<Buffer *> &in) const { 00151 Buffer &redLine = *in[0]; 00152 Buffer &greenLine = *in[1]; 00153 Buffer &blueLine = *in[2]; 00154 Buffer &alphaLine = *in[3]; 00155 00156 for (int i = 0; i < redLine.SampleDimension(); i++) { 00157 int red = getPixel(redLine[i]); 00158 int green = getPixel(greenLine[i]); 00159 int blue = getPixel(blueLine[i]); 00160 int alpha = getPixel(alphaLine[i]); 00161 00162 setBuffer(i, 0, red); 00163 setBuffer(i, 1, green); 00164 setBuffer(i, 2, blue); 00165 setBuffer(i, 3, alpha); 00166 } 00167 00168 writeLine(redLine.Line() - 1); 00169 } 00170 }; 00171