diff --git a/stim/envi/bil.h b/stim/envi/bil.h index f80f909..4110fd1 100644 --- a/stim/envi/bil.h +++ b/stim/envi/bil.h @@ -419,7 +419,7 @@ public: /// @param outname is the name of the output BIP file to be saved to disk. bool bip(std::string outname, bool PROGRESS = false) { - unsigned int S = X() * Z() * sizeof(T); //calculate the number of bytes in a ZX slice + unsigned long long S = X() * Z() * sizeof(T); //calculate the number of bytes in a ZX slice std::ofstream target(outname.c_str(), std::ios::binary); std::string headername = outname + ".hdr"; @@ -844,7 +844,7 @@ public: /// Saves to disk only those spectra corresponding to mask values != 0 /// Unlike the BIP and BSQ versions of this function, this version saves a different format: the BIL file is saved as a BIP - bool sift(std::string outfile, unsigned char* p){ + bool sift(std::string outfile, unsigned char* p, bool PROGRESS = false){ // Assume X() = X, Y() = Y, Z() = Z. std::ofstream target(outfile.c_str(), std::ios::binary); @@ -878,14 +878,13 @@ public: target.write((char*)spec, B * sizeof(T)); //write that spectrum to disk. Size is L2. } - progress = (double) (y * X() + x) / (Y() * X()) * 100; + if(PROGRESS) progress = (double) ((y+1) * X() + x+1) / (Y() * X()) * 100; } } target.close(); free(slice); free(spec); - progress = 100; return true; } diff --git a/stim/envi/bip.h b/stim/envi/bip.h index d4b90b0..8ae98b8 100644 --- a/stim/envi/bip.h +++ b/stim/envi/bip.h @@ -836,7 +836,7 @@ public: /// Saves to disk only those spectra corresponding to mask values != 0 - bool sift(std::string outfile, unsigned char* mask){ + bool sift(std::string outfile, unsigned char* mask, bool PROGRESS = false){ //reset the file pointer to the beginning of the file file.seekg(0, std::ios::beg); @@ -875,7 +875,7 @@ public: //write this pixel out target.write((char *)spectrum, B * sizeof(T)); - progress = (double) x / XY * 100; + if(PROGRESS) progress = (double) (x+1) / XY * 100; } } @@ -884,8 +884,6 @@ public: target.close(); free(spectrum); - progress = 100; - return true; } diff --git a/stim/envi/bsq.h b/stim/envi/bsq.h index 6c5c180..e6a61ad 100644 --- a/stim/envi/bsq.h +++ b/stim/envi/bsq.h @@ -324,59 +324,35 @@ public: return true; } - /// Convert the current BSQ file to a BIP file with the specified file name. - - /// @param outname is the name of the output BIP file to be saved to disk. - /*bool bip(std::string outname) - { - std::string temp = outname + "_temp"; - std::string headtemp = temp + ".hdr"; - //first creat a temporary bil file and convert bsq file to bil file - bil(temp); - - stim::bil n; - if(n.open(temp, X(), Y(), Z(), offset, w)==false){ //open infile - std::cout<<"ERROR: unable to open input file"<(xz_slice), xz_bytes); //write the generated XZ slice to the target file + //std::cout<*)file)->sift(outfile, p); + return ((bsq*)file)->sift(outfile, p, PROGRESS); else if (header.data_type == envi_header::float64) - return ((bsq*)file)->sift(outfile, p); + return ((bsq*)file)->sift(outfile, p, PROGRESS); else std::cout << "ERROR: unidentified data type" << std::endl; } else if (header.interleave == envi_header::BIL){ //if the infile is bil file if (header.data_type == envi_header::float32) - return ((bil*)file)->sift(outfile, p); + return ((bil*)file)->sift(outfile, p, PROGRESS); else if (header.data_type == envi_header::float64) - return ((bil*)file)->sift(outfile, p); + return ((bil*)file)->sift(outfile, p, PROGRESS); else std::cout << "ERROR: unidentified data type" << std::endl; } else if (header.interleave == envi_header::BIP){ //if the infile is bip file if (header.data_type == envi_header::float32) - return ((bip*)file)->sift(outfile, p); + return ((bip*)file)->sift(outfile, p, PROGRESS); else if (header.data_type == envi_header::float64) - return ((bip*)file)->sift(outfile, p); + return ((bip*)file)->sift(outfile, p, PROGRESS); else std::cout << "ERROR: unidentified data type" << std::endl; } -- libgit2 0.21.4