Skip to content

Commit 2e508b3

Browse files
committed
Support image width and height larger than 32767
Builds now can define LARGE_IMAGES to use 32 bit for image dimensions instead of 16 bit. Signed-off-by: Stefan Weil <[email protected]>
1 parent 59fbad0 commit 2e508b3

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

src/ccstruct/mod128.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
namespace tesseract {
2222

23-
static const int16_t idirtab[] = {
23+
static const TDimension idirtab[] = {
2424
1000, 0, 998, 49, 995, 98, 989, 146, 980, 195, 970, 242, 956, 290, 941,
2525
336, 923, 382, 903, 427, 881, 471, 857, 514, 831, 555, 803, 595, 773, 634,
2626
740, 671, 707, 707, 671, 740, 634, 773, 595, 803, 555, 831, 514, 857, 471,

src/ccstruct/points.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,32 @@ bool FCOORD::normalise() { // Convert to unit vec
4040
return true;
4141
}
4242

43+
// Deserialize an ICOORD.
44+
// For compatibility reasons it uses unsigned 16 bit coordinates
45+
// instead of 32 bit coordinates.
4346
bool ICOORD::DeSerialize(TFile *f) {
44-
return f->DeSerialize(&xcoord) && f->DeSerialize(&ycoord);
47+
bool success = false;
48+
uint16_t coord;
49+
if (f->DeSerialize(&coord)) {
50+
xcoord = coord;
51+
if (f->DeSerialize(&coord)) {
52+
ycoord = coord;
53+
success = true;
54+
}
55+
}
56+
return success;
4557
}
4658

59+
// Serialize an ICOORD.
60+
// For compatibility reasons it uses unsigned 16 bit coordinates
61+
// instead of 32 bit coordinates.
4762
bool ICOORD::Serialize(TFile *f) const {
48-
return f->Serialize(&xcoord) && f->Serialize(&ycoord);
63+
uint16_t coord;
64+
coord = xcoord;
65+
auto success = f->Serialize(&coord);
66+
coord = ycoord;
67+
success = success && f->Serialize(&coord);
68+
return success;
4969
}
5070

5171
// Set from the given x,y, shrinking the vector to fit if needed.

src/textord/tordmain.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,8 @@ void assign_blobs_to_blocks2(Image pix,
209209
**********************************************************************/
210210

211211
void Textord::find_components(Image pix, BLOCK_LIST *blocks, TO_BLOCK_LIST *to_blocks) {
212-
int width = pixGetWidth(pix);
213-
int height = pixGetHeight(pix);
214-
if (width > INT16_MAX || height > INT16_MAX) {
215-
tprintf("Input image too large! (%d, %d)\n", width, height);
216-
return; // Can't handle it.
217-
}
212+
auto width = pixGetWidth(pix);
213+
auto height = pixGetHeight(pix);
218214

219215
BLOCK_IT block_it(blocks); // iterator
220216
for (block_it.mark_cycle_pt(); !block_it.cycled_list(); block_it.forward()) {

0 commit comments

Comments
 (0)