keep API compatibility with #1265

This commit is contained in:
zdenop 2018-10-09 11:22:15 +02:00
parent 7be5f74df8
commit c375f4fbf7
5 changed files with 14 additions and 15 deletions

View File

@ -67,9 +67,9 @@ TESS_API TessResultRenderer* TESS_CALL TessHOcrRendererCreate2(const char* outpu
}
TESS_API TessResultRenderer* TESS_CALL TessPDFRendererCreate(const char* outputbase, const char* datadir,
BOOL textonly, int jpg_quality)
BOOL textonly)
{
return new TessPDFRenderer(outputbase, datadir, textonly, jpg_quality);
return new TessPDFRenderer(outputbase, datadir, textonly);
}
TESS_API TessResultRenderer* TESS_CALL TessUnlvRendererCreate(const char* outputbase)

View File

@ -127,7 +127,7 @@ TESS_API TessResultRenderer* TESS_CALL TessTextRendererCreate(const char* output
TESS_API TessResultRenderer* TESS_CALL TessHOcrRendererCreate(const char* outputbase);
TESS_API TessResultRenderer* TESS_CALL TessHOcrRendererCreate2(const char* outputbase, BOOL font_info);
TESS_API TessResultRenderer* TESS_CALL TessPDFRendererCreate(const char* outputbase, const char* datadir,
BOOL textonly, int jpg_quality);
BOOL textonly);
TESS_API TessResultRenderer* TESS_CALL TessUnlvRendererCreate(const char* outputbase);
TESS_API TessResultRenderer* TESS_CALL TessBoxTextRendererCreate(const char* outputbase);

View File

@ -179,14 +179,12 @@ static const int kMaxBytesPerCodepoint = 20;
/**********************************************************************
* PDF Renderer interface implementation
**********************************************************************/
TessPDFRenderer::TessPDFRenderer(const char *outputbase, const char *datadir,
bool textonly, int jpg_quality)
bool textonly)
: TessResultRenderer(outputbase, "pdf"),
datadir_(datadir) {
obj_ = 0;
textonly_ = textonly;
jpg_quality_ = jpg_quality;
offsets_.push_back(0);
}
@ -700,7 +698,8 @@ bool TessPDFRenderer::imageToPDFObj(Pix *pix,
const char* filename,
long int objnum,
char **pdf_object,
long int *pdf_object_size, int jpg_quality) {
long int* pdf_object_size,
const int jpg_quality) {
size_t n;
char b0[kBasicBufSize];
char b1[kBasicBufSize];
@ -713,13 +712,12 @@ bool TessPDFRenderer::imageToPDFObj(Pix *pix,
return false;
L_Compressed_Data *cid = nullptr;
const int kJpegQuality = jpg_quality;
int format, sad;
if (pixGetInputFormat(pix) == IFF_PNG)
sad = pixGenerateCIData(pix, L_FLATE_ENCODE, 0, 0, &cid);
if (!cid) {
sad = l_generateCIDataForPdf(filename, pix, kJpegQuality, &cid);
sad = l_generateCIDataForPdf(filename, pix, jpg_quality, &cid);
}
if (sad || !cid) {
@ -910,7 +908,10 @@ bool TessPDFRenderer::AddImageHandler(TessBaseAPI* api) {
if (!textonly_) {
char *pdf_object = nullptr;
if (!imageToPDFObj(pix, filename, obj_, &pdf_object, &objsize, jpg_quality_)) {
int jpg_quality;
api->GetIntVariable("jpg_quality", &jpg_quality);
if (!imageToPDFObj(pix, filename, obj_, &pdf_object, &objsize,
jpg_quality)) {
return false;
}
AppendData(pdf_object, objsize);

View File

@ -187,7 +187,7 @@ class TESS_API TessPDFRenderer : public TessResultRenderer {
public:
// datadir is the location of the TESSDATA. We need it because
// we load a custom PDF font from this location.
TessPDFRenderer(const char* outputbase, const char* datadir, bool textonly = false, int jpg_quality = 85);
TessPDFRenderer(const char* outputbase, const char* datadir, bool textonly = false);
protected:
virtual bool BeginDocumentHandler();
@ -214,7 +214,7 @@ class TESS_API TessPDFRenderer : public TessResultRenderer {
char* GetPDFTextObjects(TessBaseAPI* api, double width, double height);
// Turn an image into a PDF object. Only transcode if we have to.
static bool imageToPDFObj(Pix* pix, const char* filename, long int objnum,
char** pdf_object, long int* pdf_object_size, int jpg_quality);
char** pdf_object, long int* pdf_object_size, const int jpg_quality);
};

View File

@ -418,10 +418,8 @@ static void PreloadRenderers(
#endif // WIN32
bool textonly;
api->GetBoolVariable("textonly_pdf", &textonly);
int jpg_quality;
api->GetIntVariable("jpg_quality", &jpg_quality);
renderers->push_back(new tesseract::TessPDFRenderer(
outputbase, api->GetDatapath(), textonly, jpg_quality));
outputbase, api->GetDatapath(), textonly));
}
api->GetBoolVariable("tessedit_write_unlv", &b);