Skip to content

Commit 025689f

Browse files
committed
Fixed damage to binary images when processing PDFs, issue #535
1 parent 7744da9 commit 025689f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ccmain/thresholder.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,11 @@ void ImageThresholder::SetImage(const Pix* pix) {
181181
// Caller must use pixDestroy to free the created Pix.
182182
void ImageThresholder::ThresholdToPix(PageSegMode pageseg_mode, Pix** pix) {
183183
if (pix_channels_ == 0) {
184-
// We have a binary image, so it just has to be cloned.
185-
*pix = GetPixRect();
184+
// We have a binary image, but it still has to be copied, as this API
185+
// allows the caller to modify the output.
186+
Pix* original = GetPixRect();
187+
*pix = pixCopy(nullptr, original);
188+
pixDestroy(&original);
186189
} else {
187190
OtsuThresholdRectToPix(pix_, pix);
188191
}

0 commit comments

Comments
 (0)