94int main(
int argc,
char* argv[]) {
97 std::cerr <<
"Usage: SpecSep2Tiff output_file compress_flag sep_flag infile_fmt_file start_nm end_nm inc_nm [embedded_icc_profile_file]\n";
106 int start, end, step, n;
109 bool bCompress = atoi(argv[2]) != 0;
110 bool bSep = atoi(argv[3]) != 0;
112 start = atoi(argv[5]);
114 step = atoi(argv[7]);
117 std::cerr <<
"Error: increment ('inc_nm') cannot be zero.\n";
121 n = (end - start) / step + 1;
123 for (i=0; i<n; i++) {
124 sprintf(filename, argv[4], i*step + start);
125 if (!infile[i].Open(filename)) {
126 printf(
"Cannot open %s\n", filename);
130 if (infile[i].GetSamples() != 1) {
131 printf(
"%s does not have 1 sampleperpixel\n", filename);
135 if (infile[i].GetPhoto() == PHOTOMETRIC_PALETTE) {
136 printf(
"%s is a palette based file\n", filename);
140 if (i && (infile[i].GetWidth() != infile[0].GetWidth() ||
141 infile[i].GetHeight() != infile[i-1].GetHeight() ||
142 infile[i].GetBitsPerSample() != infile[i-1].GetBitsPerSample() ||
143 infile[i].GetPhoto() != infile[i-1].GetPhoto() ||
144 infile[i].GetXRes() != infile[i-1].GetXRes() ||
145 infile[i].GetYRes() != infile[i-1].GetYRes())) {
146 printf(
"%s doesn't have same format as other files\n", filename);
156 printf(
"Photometric must be MinIsWhite or MinIsBlack\n");
166 if (!inbuf || !buf) {
167 printf(
"Memory allocation error!\n");
180 n, xRes, yRes, bCompress, bSep)) {
183 unsigned long length = 0;
187 if (io.
Open(argv[8],
"r")) {
191 io.
Read8(pDestProfile, length);
200 for (j=0; j<n; j++) {
201 sptr = inbuf + j*bpl;
202 if (!infile[j].ReadLine(sptr)) {
203 printf(
"Error reading line %d of file %d\n", i, j);
207 for (k=bpl; k>0; k--) {
214 for (k=0; k<(int)f->
GetWidth(); k++) {
215 for (j=0; j<n; j++) {
216 sptr = inbuf + j*bpl + k*bps;
217 memcpy(tptr, sptr, bps);
223 printf(
"Image successfully written!\n");
226 printf(
"Unable to create %s\n", argv[1]);
bool Create(const char *szFname, unsigned int nWidth, unsigned int nHeight, unsigned int nBPS, unsigned int nPhoto, unsigned int nSamples, float fXRes, float fYRes, bool bCompress=true, bool bSep=false)