Skip to content

Commit

Permalink
Fix broken synthesize-gray option
Browse files Browse the repository at this point in the history
  • Loading branch information
SimulPiscator committed Mar 31, 2022
1 parent 8e5dc45 commit 7ecfff3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion server/optionsfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ OptionsFile::scannerOptions(const Scanner* pScanner) const
else if (option.first == "color-gamma")
processedOptions.color_gamma = ::atof(option.second.c_str());
else if (option.first == "synthesize-gray")
processedOptions.synthesize_gray = (option.second == "true");
processedOptions.synthesize_gray = (option.second == "true" || option.second == "yes");
else
processedOptions.sane_options.push_back(option);
}
Expand Down
21 changes: 11 additions & 10 deletions server/scanjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,15 +643,16 @@ ScanJob::Private::finishTransfer(std::ostream& os)
pEncoder->setHeight(p->lines);
pEncoder->setBitDepth(p->depth);
pEncoder->setDestination(&os);
if (mDeviceOptions.synthesize_gray && pEncoder->bytesPerLine() != p->bytes_per_line / 3) {
std::cerr << __FILE__ << ", line " << __LINE__
<< ": encoder bytesPerLine (" << pEncoder->bytesPerLine()
<< ") differs from SANE bytes_per_line/3 ("
<< p->bytes_per_line / 3 << ")" << std::endl;
mState = aborted;
mStateReason = PWG_ERRORS_DETECTED;
} else if (!mDeviceOptions.synthesize_gray &&
pEncoder->bytesPerLine() != p->bytes_per_line) {
if (!mColorScan && mDeviceOptions.synthesize_gray) {
if (pEncoder->bytesPerLine() != p->bytes_per_line / 3) {
std::cerr << __FILE__ << ", line " << __LINE__
<< ": encoder bytesPerLine (" << pEncoder->bytesPerLine()
<< ") differs from SANE bytes_per_line/3 ("
<< p->bytes_per_line / 3 << ")" << std::endl;
mState = aborted;
mStateReason = PWG_ERRORS_DETECTED;
}
} else if (pEncoder->bytesPerLine() != p->bytes_per_line) {
std::cerr << __FILE__ << ", line " << __LINE__
<< ": encoder bytesPerLine (" << pEncoder->bytesPerLine()
<< ") differs from SANE bytes_per_line (" << p->bytes_per_line
Expand All @@ -667,7 +668,7 @@ ScanJob::Private::finishTransfer(std::ostream& os)
status = mpSession->read(buffer).status();
if (status == SANE_STATUS_GOOD) {
applyGamma(buffer);
if (mDeviceOptions.synthesize_gray)
if (!mColorScan && mDeviceOptions.synthesize_gray)
synthesizeGray(buffer);
try {
pEncoder->writeLine(buffer.data());
Expand Down

0 comments on commit 7ecfff3

Please sign in to comment.