Browse Source

Getting extremely small values for height

refactor
suhrke 5 years ago
parent
commit
562ce92603
  1. 38
      source/Printer.cpp
  2. 13
      source/main.cpp

38
source/Printer.cpp

@ -361,13 +361,13 @@ void Initializeprinting(t_printdata *print) { @@ -361,13 +361,13 @@ void Initializeprinting(t_printdata *print) {
// less sound defaults.
// print->dc=NULL;
// print->frompage=0;
// print->topage=9999;
// if (resx==0 || resy==0) {
// print->ppix=300; print->ppiy=300;
// } else {
// print->ppix=resx; print->ppiy=resy;
// }
print->frompage=0;
print->topage=9999;
if (resx==0 || resy==0) {
print->ppix=300; print->ppiy=300;
} else {
print->ppix=resx; print->ppiy=resy;
}
// if (pagesetup.Flags & PSD_INTHOUSANDTHSOFINCHES) {
// width=pagesetup.ptPaperSize.x*print->ppix/1000;
// height=pagesetup.ptPaperSize.y*print->ppiy/1000;
@ -400,10 +400,10 @@ void Initializeprinting(t_printdata *print) { @@ -400,10 +400,10 @@ void Initializeprinting(t_printdata *print) {
// print->bordertop=pagesetup.rtMargin.top*print->ppiy/2540;
// print->borderbottom=pagesetup.rtMargin.bottom*print->ppiy/2540;
// } else {
// print->borderleft=print->ppix;
// print->borderright=print->ppix/2;
// print->bordertop=print->ppiy/2;
// print->borderbottom=print->ppiy/2;
print->borderleft=print->ppix;
print->borderright=print->ppix/2;
print->bordertop=print->ppiy/2;
print->borderbottom=print->ppiy/2;
// }
@ -432,6 +432,22 @@ void Initializeprinting(t_printdata *print) { @@ -432,6 +432,22 @@ void Initializeprinting(t_printdata *print) {
// 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;
if (nx<print->redundancy+1 || ny<3 || nx*ny<2*print->redundancy+2) {
Reporterror("Printable area is too small, reduce borders or block size");
Stopprinting(print);

13
source/main.cpp

@ -44,9 +44,12 @@ inline bool isSwitchValid(int value) @@ -44,9 +44,12 @@ inline bool isSwitchValid(int value)
// dpi 40 to 300
bool validate(cxxopts::Options &o)
{
cout << "no-header: " << o["no-header"].as<int>() << endl;
cout << "border: " << o["border"].as<int>() << endl;
bool is_ok = true;
if ((o["mode"].as<string>().compare("encode") != 0) &&
o["mode"].as<string>().compare("decode") != 0) {
cerr << "error: invalid mode given" << endl;
is_ok = false;
}
if (o["i"].as<string>().empty()) {
cerr << "error: no input file given" << endl;
is_ok = false;
@ -67,11 +70,6 @@ bool validate(cxxopts::Options &o) @@ -67,11 +70,6 @@ bool validate(cxxopts::Options &o)
cerr << "error: invalid value for redundancy" << endl;
is_ok = false;
}
if ((o["mode"].as<string>().compare("encode") != 0) &&
o["mode"].as<string>().compare("decode") != 0) {
cerr << "error: invalid mode given" << endl;
is_ok = false;
}
if ( isSwitchValid(o["no-header"].as<int>()) ) {
cerr << "error: invalid value given for no-header switch" << endl;
is_ok = false;
@ -122,6 +120,7 @@ cxxopts::Options arguments(int ac, char **av) { @@ -122,6 +120,7 @@ cxxopts::Options arguments(int ac, char **av) {
o.parse(ac, av);
if (o.count("help")) {
cout << o.help() << endl;
exit(EXIT_SUCCESS);
}else if (o.count("version")) {
cout << "\nPaperBack v" << VERSIONHI << "." << VERSIONLO << endl
<< "Copyright © 2007 Oleh Yuschuk" << endl << endl

Loading…
Cancel
Save