Browse Source

struct printout functions added

refactor
suhrke 3 years ago
parent
commit
7e8acbda47
6 changed files with 151 additions and 24 deletions
  1. 3
    0
      .gitignore
  2. 78
    11
      source/Decoder.h
  3. 4
    4
      source/Global.h
  4. 3
    4
      source/Printer.cpp
  5. 61
    5
      source/Printer.h
  6. 2
    0
      source/main.cpp

+ 3
- 0
.gitignore View File

@@ -15,3 +15,6 @@
# executables
paperback-cli

# files from tools
tags


+ 78
- 11
source/Decoder.h View File

@@ -33,12 +33,17 @@ typedef struct t_procdata { // Descriptor of processed data
uchar *data; // Pointer to bitmap
int sizex; // X bitmap size, pixels
int sizey; // Y bitmap size, pixels
int gridxmin,gridxmax; // Rought X grid limits, pixels
int gridymin,gridymax; // Rought Y grid limits, pixels
int searchx0,searchx1; // X grid search limits, pixels
int searchy0,searchy1; // Y grid search limits, pixels
int gridxmin; // Rought X grid limits, pixels
int gridxmax; // Rought X grid limits, pixels
int gridymin; // Rought Y grid limits, pixels
int gridymax; // Rought Y grid limits, pixels
int searchx0; // X grid search limits, pixels
int searchx1; // X grid search limits, pixels
int searchy0; // Y grid search limits, pixels
int searchy1; // Y grid search limits, pixels
int cmean; // Mean grid intensity (0..255)
int cmin,cmax; // Minimal and maximal grid intensity
int cmin; // Minimal and maximal grid intensity
int cmax; // Minimal and maximal grid intensity
float sharpfactor; // Estimated sharpness correction factor
float xpeak; // Base X grid line, pixels
float xstep; // X grid step, pixels
@@ -47,16 +52,22 @@ typedef struct t_procdata { // Descriptor of processed data
float ystep; // Y grid step, pixels
float yangle; // Y tilt, radians
float blockborder; // Relative width of border around block
int bufdx,bufdy; // Dimensions of block buffers, pixels
uchar *buf1,*buf2; // Rotated and sharpened block
int *bufx,*bufy; // Block grid data finders
int bufdx; // Dimensions of block buffers, pixels
int bufdy; // Dimensions of block buffers, pixels
uchar *buf1; // Rotated and sharpened block
uchar *buf2; // Rotated and sharpened block
int *bufx; // Block grid data finders
int *bufy; // Block grid data finders
uchar *unsharp; // Either buf1 or buf2
uchar *sharp; // Either buf1 or buf2
float blockxpeak,blockypeak;// Exact block position in unsharp
float blockxstep,blockystep;// Exact block dimensions in unsharp
float blockxpeak; // Exact block position in unsharp
float blockypeak; // Exact block position in unsharp
float blockxstep; // Exact block dimensions in unsharp
float blockystep; // Exact block dimensions in unsharp
int nposx; // Number of blocks to scan in X
int nposy; // Number of blocks to scan in X
int posx,posy; // Next block to scan
int posx; // Next block to scan
int posy; // Next block to scan
t_data uncorrected; // Data before ECC for block display
t_block *blocklist; // List of blocks recognized on page
t_superblock superblock; // Page header
@@ -68,6 +79,62 @@ typedef struct t_procdata { // Descriptor of processed data
int nrestored; // Page statistics: restored bytes
} t_procdata;


inline void print_procdata(t_procdata &pd) {
using namespace std;
cout << "step: " << pd.step << endl;
cout << "mode: " << pd.mode << endl;
cout << "*data: " << *pd.data << endl;
cout << "sizex: " << pd.sizex << endl;
cout << "sizey: " << pd.sizey << endl;
cout << "gridxmin: " << pd.gridxmin << endl;
cout << "gridxmax: " << pd.gridxmax << endl;
cout << "gridymin: " << pd.gridymin << endl;
cout << "gridymax: " << pd.gridymax << endl;
cout << "searchx0: " << pd.searchx0 << endl;
cout << "searchx1: " << pd.searchx1 << endl;
cout << "searchy0: " << pd.searchy0 << endl;
cout << "searchy1: " << pd.searchy1 << endl;
cout << "cmean: " << pd.cmean << endl;
cout << "cmin: " << pd.cmin << endl;
cout << "cmax: " << pd.cmax << endl;
cout << "sharpfactor: " << pd.sharpfactor << endl;
cout << "xpeak: " << pd.xpeak << endl;
cout << "xstep: " << pd.xstep << endl;
cout << "xangle: " << pd.xangle << endl;
cout << "ypeak: " << pd.ypeak << endl;
cout << "ystep: " << pd.ystep << endl;
cout << "yangle: " << pd.yangle << endl;
cout << "blockborder: " << pd.blockborder << endl;
cout << "bufdx: " << pd.bufdx << endl;
cout << "bufdy: " << pd.bufdy << endl;
cout << "*buf1: " << *pd.buf1 << endl;
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;
cout << "blockxpeak: " << pd.blockxpeak << endl;
cout << "blockypeak: " << pd.blockypeak << endl;
cout << "blockxstep: " << pd.blockxstep << endl;
cout << "blockystep: " << pd.blockystep << endl;
cout << "nposx: " << pd.nposx << endl;
cout << "nposy: " << pd.nposy << endl;
cout << "posx: " << pd.posx << endl;
cout << "posy: " << pd.posy << endl;
print_data(pd.uncorrected);
cout << "*blocklist is non-NULL: " << (pd.blocklist!=0) << endl;
print_superblock(pd.superblock);
cout << "maxdotsize: " << pd.maxdotsize << endl;
cout << "orientation: " << pd.orientation << endl;
cout << "ngood: " << pd.ngood << endl;
cout << "nbad: " << pd.nbad << endl;
cout << "nsuper: " << pd.nsuper << endl;
cout << "nrestored: " << pd.nrestored << endl;
}



//unique
extern int orientation; // Orientation of bitmap (-1: unknown)
//unique

+ 4
- 4
source/Global.h View File

@@ -175,10 +175,10 @@ inline int Filetimetotext(FILETIME *fttime,char *s,int n) {

inline void print_data(t_data &x) {
std::cout
<< "addr: " << addr
<< "data: " << data
<< "crc: " << crc
<< "ecc: " << ecc
<< "addr: " << x.addr
<< "data: " << x.data
<< "crc: " << x.crc
<< "ecc: " << x.ecc
<< std::endl;
}


+ 3
- 4
source/Printer.cpp View File

@@ -45,7 +45,6 @@ int printborder; // Border around bitmap
t_printdata printdata; // extern



// Sends specified file to printer (bmp=NULL) or to bitmap file.
t_printdata Printfile(const std::string &path, const std::string &bmp)
{
@@ -173,14 +172,14 @@ int Preparefiletoprint(t_printdata *print) {
if (print->origsize == 0
|| print -> origsize == INVALID_FILE_SIZE
|| print->origsize>MAXSIZE
|| l!=0) {
std::cout << print -> origsize << "," << l << "," << std::endl;
|| l!=0
) {
std::cout << print -> origsize << "," << l << "," << std::endl;
Reporterror("Invalid file size");
Stopprinting(print);
return -1;
};
#elif __linux
//!!!TEST struct mem allocation
// Get file attributes
if ( stat(print->infile.c_str(), &(print->attributes)) != 0 ) {
Reporterror("Unable to get input file attributes");

+ 61
- 5
source/Printer.h View File

@@ -79,9 +79,12 @@ typedef struct t_printdata { // Print control structure
int borderright; // Right page border, pixels
int bordertop; // Top page border, pixels
int borderbottom; // Bottom page border, pixels
int dx,dy; // Distance between dots, pixels
int px,py; // Dot size, pixels
int nx,ny; // Grid dimensions, blocks
int dx; // Distance between dots, pixels
int dy; // Distance between dots, pixels
int px; // Dot size, pixels
int py; // Dot size, pixels
int nx; // Grid dimensions, blocks
int ny; // Grid dimensions, blocks
int border; // Border around the data grid, pixels
uchar *dibbits; // Pointer to DIB bits
uchar *drawbits; // Pointer to file bitmap bits
@@ -90,6 +93,59 @@ typedef struct t_printdata { // Print control structure
} t_printdata;


inline void print_printdata(t_printdata& pd) {
using namespace std;
cout << "step: " << pd.step << endl;
cout << "infile: " << pd.infile << endl;
cout << "outbmp: " << pd.outbmp << endl;
#ifdef _WIN32
cout << "hfile: " << pd.hfile << endl;
cout << "modified: " << pd.modified << endl;
cout << "hbmp: " << pd.hbmp << endl;
cout << "attributes: " << pd.attributes << endl;
#elif __linux__
cout << "*hfile is non-NULL: " << (pd.hfile != 0) << endl;
cout << "attributes is non-NULL: " << (&pd.attributes != 0) << endl;
cout << "modified: " << pd.modified << endl;
#endif
cout << "origsize: " << pd.origsize << endl;
cout << "readsize: " << pd.readsize << endl;
cout << "pagesize: " << pd.pagesize << endl;
cout << "printheader: " << pd.printheader << endl;
cout << "printborder: " << pd.printborder << endl;
cout << "redundancy: " << pd.redundancy << endl;
cout << "*buf: " << *pd.buf << endl;
cout << "bufsize: " << pd.bufsize << endl;
cout << "*readbuf: " << *pd.readbuf << endl;
cout << "bufcrc: " << pd.bufcrc << endl;
print_superdata(pd.superdata);
cout << "frompage: " << pd.frompage << endl;
cout << "topage: " << pd.topage << endl;
cout << "ppix: " << pd.ppix << endl;
cout << "ppiy: " << pd.ppiy << endl;
cout << "width: " << pd.width << endl;
cout << "height: " << pd.height << endl;
cout << "extratop: " << pd.extratop << endl;
cout << "extrabottom: " << pd.extrabottom << endl;
cout << "black: " << pd.black << endl;
cout << "borderleft: " << pd.borderleft << endl;
cout << "borderright: " << pd.borderright << endl;
cout << "bordertop: " << pd.bordertop << endl;
cout << "borderbottom: " << pd.borderbottom << endl;
cout << "dx: " << pd.dx << endl;
cout << "dy: " << pd.dy << endl;
cout << "px: " << pd.px << endl;
cout << "py: " << pd.py << endl;
cout << "nx: " << pd.nx << endl;
cout << "ny: " << pd.ny << endl;
cout << "border: " << pd.border << endl;
cout << "*dibbits: " << *pd.dibbits << endl;
cout << "*drawbits: " << *pd.drawbits << endl;
cout << "*bmi: " << *pd.bmi << endl;
cout << "startdoc: " << pd.startdoc << endl;
}


//uniques (should not have copies of)
extern int resx,resy; // Printer resolution, dpi (may be 0!)
extern t_printdata printdata; // Print control structure
@@ -100,7 +156,7 @@ int Initializeprinting(t_printdata *print, uint pageWidth, uint pageHeight);
void Stopprinting(t_printdata *print);
void Printnextpage(t_printdata *print);
static void Drawblock(int index,t_data *block,uchar *bits,int width,int height,
int border,int nx,int ny,int dx,int dy,int px,int py,int black);
int border,int nx,int ny,int dx,int dy,int px,int py,int black);
static void Fillblock(int blockx,int blocky,uchar *bits,int width,int height,
int border,int nx,int ny,int dx,int dy,int px,int py,int black);
int border,int nx,int ny,int dx,int dy,int px,int py,int black);
#endif

+ 2
- 0
source/main.cpp View File

@@ -174,6 +174,7 @@ 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 );
}
}
@@ -195,6 +196,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 ) {
print_procdata(procdata);
Decodenextblock(&procdata);
}
// Passes converted data to File Processor and frees recources

Loading…
Cancel
Save