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 authored and zdenop committed Dec 7, 2016
1 parent 4535d24 commit 2298bdd
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 2298bdd

Please sign in to comment.