mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
remove alpha channel from png: issue #1914
This commit is contained in:
parent
971fe50031
commit
5fe1390748
@ -611,6 +611,13 @@ void TessBaseAPI::SetSourceResolution(int ppi) {
|
||||
*/
|
||||
void TessBaseAPI::SetImage(Pix* pix) {
|
||||
if (InternalSetImage()) {
|
||||
if (pixGetSpp(pix) == 4 && pixGetInputFormat(pix) == IFF_PNG) {
|
||||
// remove alpha channel from png
|
||||
PIX* p1 = pixRemoveAlpha(pix);
|
||||
pixSetSpp(p1, 3);
|
||||
pix = pixCopy(nullptr, p1);
|
||||
pixDestroy(&p1);
|
||||
}
|
||||
thresholder_->SetImage(pix);
|
||||
SetInputImage(thresholder_->GetPixRect());
|
||||
}
|
||||
|
@ -716,14 +716,7 @@ bool TessPDFRenderer::imageToPDFObj(Pix *pix,
|
||||
const int kJpegQuality = jpg_quality;
|
||||
|
||||
int format, sad;
|
||||
if (filename) {
|
||||
findFileFormat(filename, &format);
|
||||
if (pixGetSpp(pix) == 4 && format == IFF_PNG) {
|
||||
Pix *p1 = pixAlphaBlendUniform(pix, 0xffffff00);
|
||||
sad = pixGenerateCIData(p1, L_FLATE_ENCODE, 0, 0, &cid);
|
||||
pixDestroy(&p1);
|
||||
}
|
||||
}
|
||||
sad = pixGenerateCIData(pix, L_FLATE_ENCODE, 0, 0, &cid);
|
||||
if (!cid) {
|
||||
sad = l_generateCIDataForPdf(filename, pix, kJpegQuality, &cid);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user