Skip to content

Commit

Permalink
Support image width and height larger than 32767
Browse files Browse the repository at this point in the history
Builds now can define LARGE_IMAGES to use 32 bit for
image dimensions instead of 16 bit.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Oct 27, 2021
1 parent 59fbad0 commit 2e508b3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/ccstruct/mod128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace tesseract {

static const int16_t idirtab[] = {
static const TDimension idirtab[] = {
1000, 0, 998, 49, 995, 98, 989, 146, 980, 195, 970, 242, 956, 290, 941,
336, 923, 382, 903, 427, 881, 471, 857, 514, 831, 555, 803, 595, 773, 634,
740, 671, 707, 707, 671, 740, 634, 773, 595, 803, 555, 831, 514, 857, 471,
Expand Down
24 changes: 22 additions & 2 deletions src/ccstruct/points.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,32 @@ bool FCOORD::normalise() { // Convert to unit vec
return true;
}

// Deserialize an ICOORD.
// For compatibility reasons it uses unsigned 16 bit coordinates
// instead of 32 bit coordinates.
bool ICOORD::DeSerialize(TFile *f) {
return f->DeSerialize(&xcoord) && f->DeSerialize(&ycoord);
bool success = false;
uint16_t coord;
if (f->DeSerialize(&coord)) {
xcoord = coord;
if (f->DeSerialize(&coord)) {
ycoord = coord;
success = true;
}
}
return success;
}

// Serialize an ICOORD.
// For compatibility reasons it uses unsigned 16 bit coordinates
// instead of 32 bit coordinates.
bool ICOORD::Serialize(TFile *f) const {
return f->Serialize(&xcoord) && f->Serialize(&ycoord);
uint16_t coord;
coord = xcoord;
auto success = f->Serialize(&coord);
coord = ycoord;
success = success && f->Serialize(&coord);
return success;
}

// Set from the given x,y, shrinking the vector to fit if needed.
Expand Down
8 changes: 2 additions & 6 deletions src/textord/tordmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,8 @@ void assign_blobs_to_blocks2(Image pix,
**********************************************************************/

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

BLOCK_IT block_it(blocks); // iterator
for (block_it.mark_cycle_pt(); !block_it.cycled_list(); block_it.forward()) {
Expand Down

0 comments on commit 2e508b3

Please sign in to comment.