Browse Source

Debugging output more readable

refactor
suhrke 3 years ago
parent
commit
7e4d9163b6
5 changed files with 48 additions and 49 deletions
  1. 22
    27
      source/Decoder.cpp
  2. 10
    2
      source/Decoder.h
  3. 13
    19
      source/Printer.cpp
  4. 2
    0
      source/Printer.h
  5. 1
    1
      source/main.cpp

+ 22
- 27
source/Decoder.cpp View File

@@ -333,10 +333,6 @@ int Getgridposition(t_procdata *pdata) {
if (distry[j]>=limit) break; };
pdata->gridymax=j*stepy;

std::cout << "pdata->gridxmax: " << pdata->gridxmax << std::endl;
std::cout << "pdata->gridymax: " << pdata->gridymax << std::endl;
std::cout << "pdata->gridxmin: " << pdata->gridxmin << std::endl;
std::cout << "pdata->gridymin: " << pdata->gridymin << std::endl;
// Step finished.
pdata->step++;
return 0;
@@ -371,7 +367,6 @@ int Getgridintensity(t_procdata *pdata) {
memset(distrc,0,sizeof(distrc));
memset(distrd,0,sizeof(distrd));
cmean=0; n=0;
std::cout << "dy: " << dy << std::endl;
for (j=0; j<dy-1; j++) {
pd=data+(searchy0+j)*sizex+searchx0;
for (i=0; i<dx-1; i++,pd++) {
@@ -1142,26 +1137,26 @@ int Decodebitmap(const std::string &fileName) {
pbih=(BITMAPINFOHEADER *)(buf+sizeof(OverlayBitmapFileHeader));
#endif

std::cout //<< pbfh << "\n"
<< "bfType: " << pbfh -> bfType << ", " << &pbfh -> bfType <<"\n"
<< "bfSize: " << pbfh -> bfSize << ", " << &pbfh -> bfSize <<"\n"
<< pbfh -> bfReserved1 << ", " << &pbfh -> bfReserved1 <<"\n"
<< pbfh -> bfReserved2 << ", " << &pbfh -> bfReserved2 <<"\n"
<< "bfOffBits : " << pbfh -> bfOffBits << ", " << &pbfh -> bfOffBits <<"\n"
<< std::endl;
std::cout //<< pbih << "\n"
<< "biSize: " << pbih -> biSize << ", " << &pbih -> biSize << "\n"
<< "biWidth: " << pbih -> biWidth << ", " << &pbih -> biWidth << "\n"
<< "biHeight: " << pbih -> biHeight << ", " << &pbih -> biHeight << "\n"
<< "biPlanes: " << pbih -> biPlanes << ", " << &pbih -> biPlanes << "\n"
<< "biBitCount: " << pbih -> biBitCount << ", " << &pbih -> biBitCount << "\n"
<< "biCompression: " << pbih -> biCompression << ", " << &pbih -> biCompression << "\n"
<< "biSizeImage: " << pbih -> biSizeImage << ", " << &pbih -> biSizeImage << "\n"
<< "biXPelsPerMeter: " << pbih -> biXPelsPerMeter << ", " << &pbih -> biXPelsPerMeter << "\n"
<< "biYPelsPerMeter: " << pbih -> biYPelsPerMeter << ", " << &pbih -> biXPelsPerMeter << "\n"
<< "biClrUsed: " << pbih -> biClrUsed << ", " << &pbih -> biClrUsed << "\n"
<< "biClrImportant: " << pbih -> biClrImportant << ", " << &pbih -> biClrImportant << "\n"
<< std::endl;
//std::cout //<< pbfh << "\n"
// << "bfType: " << pbfh -> bfType << ", " << &pbfh -> bfType <<"\n"
// << "bfSize: " << pbfh -> bfSize << ", " << &pbfh -> bfSize <<"\n"
// << pbfh -> bfReserved1 << ", " << &pbfh -> bfReserved1 <<"\n"
// << pbfh -> bfReserved2 << ", " << &pbfh -> bfReserved2 <<"\n"
// << "bfOffBits : " << pbfh -> bfOffBits << ", " << &pbfh -> bfOffBits <<"\n"
// << std::endl;
//std::cout //<< pbih << "\n"
// << "biSize: " << pbih -> biSize << ", " << &pbih -> biSize << "\n"
// << "biWidth: " << pbih -> biWidth << ", " << &pbih -> biWidth << "\n"
// << "biHeight: " << pbih -> biHeight << ", " << &pbih -> biHeight << "\n"
// << "biPlanes: " << pbih -> biPlanes << ", " << &pbih -> biPlanes << "\n"
// << "biBitCount: " << pbih -> biBitCount << ", " << &pbih -> biBitCount << "\n"
// << "biCompression: " << pbih -> biCompression << ", " << &pbih -> biCompression << "\n"
// << "biSizeImage: " << pbih -> biSizeImage << ", " << &pbih -> biSizeImage << "\n"
// << "biXPelsPerMeter: " << pbih -> biXPelsPerMeter << ", " << &pbih -> biXPelsPerMeter << "\n"
// << "biYPelsPerMeter: " << pbih -> biYPelsPerMeter << ", " << &pbih -> biXPelsPerMeter << "\n"
// << "biClrUsed: " << pbih -> biClrUsed << ", " << &pbih -> biClrUsed << "\n"
// << "biClrImportant: " << pbih -> biClrImportant << ", " << &pbih -> biClrImportant << "\n"
// << std::endl;

if ( pbfh->bfType!=19778 ) {//First two bytes must be 'BM' (19778)
std::ostringstream oss;
@@ -1175,14 +1170,14 @@ int Decodebitmap(const std::string &fileName) {
Reporterror(oss.str());
return -1;
}
std::cout << "Color bits per pixel: " << pbih->biBitCount << std::endl;
//std::cout << "Color bits per pixel: " << pbih->biBitCount << std::endl;
if ( pbih->biBitCount!=8 && pbih->biBitCount!=24) {
std::ostringstream oss;
oss << "Unsupported Bitmap: Must be 8-bit or 24-bit color: " << fileName << std::endl;
Reporterror(oss.str());
return -1;
}
std::cout << "# of colors (if 24-bit): " << pbih->biClrUsed << std::endl;
//std::cout << "# of colors (if 24-bit): " << pbih->biClrUsed << std::endl;
if ( pbih->biBitCount==24 && pbih->biClrUsed!=0) {
std::ostringstream oss;
oss << "Unsupported Bitmap: 24-bit color bitmaps required to specify number of colors used: " << fileName << std::endl;

+ 10
- 2
source/Decoder.h View File

@@ -82,6 +82,7 @@ typedef struct t_procdata { // Descriptor of processed data

inline void print_procdata(t_procdata &pd) {
using namespace std;
cout << "==============================================================================" << endl;
cout << "step: " << pd.step << endl;
cout << "mode: " << pd.mode << endl;
cout << "*data: " << *pd.data << endl;
@@ -112,8 +113,14 @@ inline void print_procdata(t_procdata &pd) {
cout << "*buf2: " << *pd.buf2 << endl;
cout << "*bufx: " << *pd.bufx << endl;
cout << "*bufy: " << *pd.bufy << endl;
cout << "*unsharp: " << *pd.unsharp << endl;
cout << "*sharp: " << *pd.sharp << endl;
if( pd.unsharp == NULL )
cout << "*unsharp is NULL " << endl;
else
cout << "*unsharp: " << *pd.unsharp << endl;
if( pd.sharp == NULL )
cout << "*sharp is NULL" << endl;
else
cout << "*sharp: " << *pd.sharp << endl;
cout << "blockxpeak: " << pd.blockxpeak << endl;
cout << "blockypeak: " << pd.blockypeak << endl;
cout << "blockxstep: " << pd.blockxstep << endl;
@@ -131,6 +138,7 @@ inline void print_procdata(t_procdata &pd) {
cout << "nbad: " << pd.nbad << endl;
cout << "nsuper: " << pd.nsuper << endl;
cout << "nrestored: " << pd.nrestored << endl;
cout << "==============================================================================" << endl;
}



+ 13
- 19
source/Printer.cpp View File

@@ -174,7 +174,6 @@ int Preparefiletoprint(t_printdata *print) {
|| print->origsize>MAXSIZE
|| l!=0
) {
std::cout << print -> origsize << "," << l << "," << std::endl;
Reporterror("Invalid file size");
Stopprinting(print);
return -1;
@@ -246,8 +245,6 @@ int Initializeprinting(t_printdata *print, uint pageWidth, uint pageHeight) {
// Prepare superdata.
print->superdata.addr=SUPERBLOCK;
print->superdata.origsize=print->origsize;
std::cout << "print->superdata.addr: " << print->superdata.addr << std::endl;
std::cout << "print->origsize: " << print->origsize << std::endl;
//if (print->compression)
// print->superdata.mode|=PBM_COMPRESSED;
//if (print->encryption)
@@ -440,22 +437,15 @@ int Initializeprinting(t_printdata *print, uint pageWidth, uint pageHeight) {
// recovery blocks should be placed into different columns.
nx=(width-px-2*print->border)/(NDOT*dx+3*dx);
ny=(height-py-2*print->border)/(NDOT*dy+3*dy);
std::cout << "nx: " << nx << std::endl;
std::cout << "ny: " << ny << std::endl;
std::cout << "width: " << width << std::endl;
std::cout << "height: " << height << std::endl;
std::cout << "print->ppix: " << print->ppix << std::endl;
std::cout << "print->ppiy: " << print->ppiy << std::endl;
std::cout << "print->bordertop: " << print->bordertop << std::endl;
std::cout << "print->borderbottom: " << print->borderbottom << std::endl;
std::cout << "print->borderleft: " << print->borderleft << std::endl;
std::cout << "print->borderright: " << print->borderright << std::endl;
std::cout << "print->border: " << print->border << std::endl;
std::cout << "px: " << px << std::endl;
std::cout << "py: " << py << std::endl;
std::cout << "NDOT: " << NDOT << std::endl;
std::cout << "dx: " << dx <<std::endl;
std::cout << "dy: " << dy << std::endl;
//std::cout << "nx: " << nx << std::endl;
//std::cout << "ny: " << ny << std::endl;
//std::cout << "width: " << width << std::endl;
//std::cout << "height: " << height << std::endl;
//std::cout << "px: " << px << std::endl;
//std::cout << "py: " << py << std::endl;
//std::cout << "NDOT: " << NDOT << std::endl;
//std::cout << "dx: " << dx <<std::endl;
//std::cout << "dy: " << dy << std::endl;
long multResult = nx*ny;
if ( nx > 0 && ny > 0 && multResult < 0 ) {
std::cerr << "Input file is too large to back up. Please break the file apart" << std::endl;
@@ -633,6 +623,10 @@ void Printnextpage(t_printdata *print) {
std::cout << "All pages have been printed" << std::endl;
return;
};

//!!! DEBUG
print_printdata(*print);

// Report page.
npages=(print->origsize+print->pagesize-1)/print->pagesize;
sprintf(s,"Processing page %i of %i...",print->frompage+1,npages);

+ 2
- 0
source/Printer.h View File

@@ -95,6 +95,7 @@ typedef struct t_printdata { // Print control structure

inline void print_printdata(t_printdata& pd) {
using namespace std;
cout << "==============================================================================" << endl;
cout << "step: " << pd.step << endl;
cout << "infile: " << pd.infile << endl;
cout << "outbmp: " << pd.outbmp << endl;
@@ -150,6 +151,7 @@ inline void print_printdata(t_printdata& pd) {
cout << "*drawbits: " << *pd.drawbits << endl;
cout << "*bmi: " << *pd.bmi << endl;
cout << "startdoc: " << pd.startdoc << endl;
cout << "==============================================================================" << endl;
}



+ 1
- 1
source/main.cpp View File

@@ -174,7 +174,6 @@ int main(int argc, char ** argv) {
//Create BMPs until all data has been written to BMP
int currStep = printdata.step;
while ( printdata.step == currStep ) {
print_printdata(printdata);
Printnextpage( &printdata );
}
}
@@ -196,6 +195,7 @@ int main(int argc, char ** argv) {
// Decode block by block until step is set to 0
int currStep = procdata.step;
while ( procdata.step == currStep ) {
///!!! DEBUG
print_procdata(procdata);
Decodenextblock(&procdata);
}

Loading…
Cancel
Save