Skip to content

Commit

Permalink
Always use L_FLATE_ENCODE in PdfRenderer (fixes #31)
Browse files Browse the repository at this point in the history
LIBRARY CHANGE
  • Loading branch information
Robyer committed Mar 2, 2021
1 parent 672ff95 commit 1181cc0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tesseract4android/src/main/cpp/leptonica/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ add_definitions(-DANDROID_BUILD)
add_definitions(-DHAVE_LIBJPEG=1)
add_definitions(-DHAVE_LIBPNG=1)
add_definitions(-DHAVE_LIBZ=1)
# TODO: Enable this when we use minSdkVersion 23 or higher and remove workaround in pdfrenderer.cpp
#add_definitions(-DHAVE_FMEMOPEN=1)

# Ignore some warnings during build
target_compile_options(leptonica PRIVATE "-Wno-address-of-packed-member")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,14 @@ bool TessPDFRenderer::imageToPDFObj(Pix *pix,

L_Compressed_Data *cid = nullptr;

#ifdef __ANDROID__ // Remove this when we use minSdkVersion 23 or higher
bool flateEncode = true;
#else
bool flateEncode = pixGetInputFormat(pix) == IFF_PNG;
#endif

int sad = 0;
if (pixGetInputFormat(pix) == IFF_PNG)
if (flateEncode)
sad = pixGenerateCIData(pix, L_FLATE_ENCODE, 0, 0, &cid);
if (!cid) {
sad = l_generateCIDataForPdf(filename, pix, jpg_quality, &cid);
Expand Down

0 comments on commit 1181cc0

Please sign in to comment.