Skip to content

Commit

Permalink
Fixed damage to binary images when processing PDFs, issue #535
Browse files Browse the repository at this point in the history
  • Loading branch information
theraysmith committed Dec 6, 2016
1 parent 7744da9 commit 025689f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ccmain/thresholder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,11 @@ void ImageThresholder::SetImage(const Pix* pix) {
// Caller must use pixDestroy to free the created Pix.
void ImageThresholder::ThresholdToPix(PageSegMode pageseg_mode, Pix** pix) {
if (pix_channels_ == 0) {
// We have a binary image, so it just has to be cloned.
*pix = GetPixRect();
// We have a binary image, but it still has to be copied, as this API
// allows the caller to modify the output.
Pix* original = GetPixRect();
*pix = pixCopy(nullptr, original);
pixDestroy(&original);
} else {
OtsuThresholdRectToPix(pix_, pix);
}
Expand Down

0 comments on commit 025689f

Please sign in to comment.