Skip to content

Commit

Permalink
Fix grey result of indexed PNG in pdfrenderer.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjbronner authored Feb 10, 2024
1 parent a7f860a commit 209cf5c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/api/pdfrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ bool TessPDFRenderer::BeginDocumentHandler() {
bool TessPDFRenderer::imageToPDFObj(Pix *pix, const char *filename, long int objnum,
char **pdf_object, long int *pdf_object_size,
const int jpg_quality) {
int sad;

if (!pdf_object_size || !pdf_object) {
return false;
}
Expand All @@ -674,14 +676,7 @@ bool TessPDFRenderer::imageToPDFObj(Pix *pix, const char *filename, long int obj
}

L_Compressed_Data *cid = nullptr;

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

if (sad || !cid) {
l_CIDataDestroy(&cid);
Expand Down

0 comments on commit 209cf5c

Please sign in to comment.