summaryrefslogtreecommitdiffstats
path: root/multimedia/ccextractor/leptonica-1.83.1.patch
blob: af419af8a7065d7f81f855ff6ae108de6d1d3838 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
diff -up ccextractor-0.94/src/lib_ccx/ocr.c.orig ccextractor-0.94/src/lib_ccx/ocr.c
--- ccextractor-0.94/src/lib_ccx/ocr.c.orig	2023-03-16 18:58:34.902356675 -0500
+++ ccextractor-0.94/src/lib_ccx/ocr.c	2023-03-16 19:00:33.481092541 -0500
@@ -1,10 +1,10 @@
 #include <math.h>
-#include "png.h"
+#include <png.h>
 #include "lib_ccx.h"
 #ifdef ENABLE_OCR
 #include <tesseract/capi.h>
-#include "ccx_common_constants.h"
 #include <leptonica/allheaders.h>
+#include "ccx_common_constants.h"
 #include <dirent.h>
 #include "ccx_encoders_helpers.h"
 #include "ocr.h"
@@ -331,6 +331,8 @@ char *ocr_bitmap(void *arg, png_color *p
 	}
 
 	BOX *crop_points = ignore_alpha_at_edge(copy->alpha, copy->data, w, h, color_pix, &color_pix_out);
+	l_int32 x, y, _w, _h;
+	boxGetGeometry(crop_points, &x, &y, &_w, &_h);
 	// Converting image to grayscale for OCR to avoid issues with transparency
 	cpix_gs = pixConvertRGBToGray(cpix, 0.0, 0.0, 0.0);
 
@@ -426,8 +428,8 @@ char *ocr_bitmap(void *arg, png_color *p
 				{
 					for (int j = x1; j <= x2; j++)
 					{
-						if (copy->data[(crop_points->y + i) * w + (crop_points->x + j)] != firstpixel)
-							histogram[copy->data[(crop_points->y + i) * w + (crop_points->x + j)]]++;
+						if (copy->data[(y + i) * w + (x + j)] != firstpixel)
+							histogram[copy->data[(y + i) * w + (x + j)]]++;
 					}
 				}
 				/* sorted in increasing order of intensity */