diff --git a/src/ccstruct/blobs.h b/src/ccstruct/blobs.h index 02ae2e8839..cfb9fa96ee 100644 --- a/src/ccstruct/blobs.h +++ b/src/ccstruct/blobs.h @@ -28,7 +28,7 @@ #include // for OcrEngineMode -#include // for int16_t +#include // for int32_t struct Pix; @@ -46,8 +46,8 @@ class WERD; ----------------------------------------------------------------------*/ struct TPOINT { - TPOINT() : x(0), y(0) {} - TPOINT(int16_t vx, int16_t vy) : x(vx), y(vy) {} + TPOINT() = default; + TPOINT(int32_t vx, int32_t vy) : x(vx), y(vy) {} TPOINT(const ICOORD &ic) : x(ic.x()), y(ic.y()) {} void operator+=(const TPOINT &other) { @@ -86,8 +86,8 @@ struct TPOINT { return x * x + y * y; } - int16_t x; // absolute x coord. - int16_t y; // absolute y coord. + int32_t x = 0; // absolute x coord. + int32_t y = 0; // absolute y coord. }; using VECTOR = TPOINT; // structure for coordinates. diff --git a/src/ccstruct/mod128.cpp b/src/ccstruct/mod128.cpp index 4b862ef535..5c9f13ea97 100644 --- a/src/ccstruct/mod128.cpp +++ b/src/ccstruct/mod128.cpp @@ -1,7 +1,7 @@ /********************************************************************** * File: mod128.cpp (Formerly dir128.c) * Description: Code to convert a DIR128 to an ICOORD. - * Author: Ray Smith + * Author: Ray Smith * * (C) Copyright 1991, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,7 +20,7 @@ namespace tesseract { -static const int16_t idirtab[] = { +static const int32_t 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, diff --git a/src/ccstruct/ocrblock.cpp b/src/ccstruct/ocrblock.cpp index 8a7fa6fa1a..619af73cd2 100644 --- a/src/ccstruct/ocrblock.cpp +++ b/src/ccstruct/ocrblock.cpp @@ -35,9 +35,9 @@ BLOCK::BLOCK(const char *name, ///< filename bool prop, ///< proportional int16_t kern, ///< kerning int16_t space, ///< spacing - int16_t xmin, ///< bottom left - int16_t ymin, int16_t xmax, ///< top right - int16_t ymax) + int32_t xmin, ///< bottom left + int32_t ymin, int32_t xmax, ///< top right + int32_t ymax) : pdblk(xmin, ymin, xmax, ymax) , filename(name) , re_rotation_(1.0f, 0.0f) diff --git a/src/ccstruct/ocrblock.h b/src/ccstruct/ocrblock.h index bde794d9bc..2a16f99dce 100644 --- a/src/ccstruct/ocrblock.h +++ b/src/ccstruct/ocrblock.h @@ -39,10 +39,10 @@ class TESS_API BLOCK : public ELIST_LINK bool prop, ///< proportional int16_t kern, ///< kerning int16_t space, ///< spacing - int16_t xmin, ///< bottom left - int16_t ymin, - int16_t xmax, ///< top right - int16_t ymax); + int32_t xmin, ///< bottom left + int32_t ymin, + int32_t xmax, ///< top right + int32_t ymax); ~BLOCK() = default; diff --git a/src/ccstruct/pdblock.cpp b/src/ccstruct/pdblock.cpp index 7ee76e6580..cac959cc25 100644 --- a/src/ccstruct/pdblock.cpp +++ b/src/ccstruct/pdblock.cpp @@ -42,9 +42,10 @@ constexpr ERRCODE LOSTBLOCKLINE("Can't find rectangle for line"); * Constructor for a simple rectangular block. **********************************************************************/ PDBLK::PDBLK( // rectangular block - int16_t xmin, // bottom left - int16_t ymin, int16_t xmax, // top right - int16_t ymax) + int32_t xmin, // bottom left + int32_t ymin, + int32_t xmax, // top right + int32_t ymax) : box(ICOORD(xmin, ymin), ICOORD(xmax, ymax)) { // boundaries ICOORDELT_IT left_it = &leftside; @@ -349,9 +350,9 @@ void BLOCK_RECT_IT::forward() { // next rectangle * Get the the start and width of a line in the block. **********************************************************************/ -int16_t BLOCK_LINE_IT::get_line( // get a line - int16_t y, // line to get - int16_t &xext // output extent +int32_t BLOCK_LINE_IT::get_line( // get a line + int32_t y, // line to get + int32_t &xext // output extent ) { ICOORD bleft; // bounding box ICOORD tright; // of block & rect diff --git a/src/ccstruct/pdblock.h b/src/ccstruct/pdblock.h index b7b2b8dd69..b92dfcdc8c 100644 --- a/src/ccstruct/pdblock.h +++ b/src/ccstruct/pdblock.h @@ -41,10 +41,10 @@ class PDBLK { index_ = 0; } /// simple constructor - PDBLK(int16_t xmin, ///< bottom left - int16_t ymin, - int16_t xmax, ///< top right - int16_t ymax); + PDBLK(int32_t xmin, ///< bottom left + int32_t ymin, + int32_t xmax, ///< top right + int32_t ymax); /// set vertex lists ///@param left list of left vertices @@ -145,8 +145,8 @@ class BLOCK_RECT_IT // rectangle iterator } private: - int16_t ymin = 0; ///< bottom of rectangle - int16_t ymax = 0; ///< top of rectangle + int32_t ymin = 0; ///< bottom of rectangle + int32_t ymax = 0; ///< top of rectangle PDBLK *block = nullptr; ///< block to iterate ICOORDELT_IT left_it; ///< boundary iterators ICOORDELT_IT right_it; @@ -172,7 +172,7 @@ class BLOCK_LINE_IT { /// get a line ///@param y line to get ///@param xext output extent - int16_t get_line(int16_t y, int16_t &xext); + int32_t get_line(int32_t y, int32_t &xext); private: PDBLK *block; ///< block to iterate diff --git a/src/ccstruct/points.h b/src/ccstruct/points.h index 61d1a162ef..cc4c8f81eb 100644 --- a/src/ccstruct/points.h +++ b/src/ccstruct/points.h @@ -43,7 +43,7 @@ class ICOORD { /// constructor ///@param xin x value ///@param yin y value - ICOORD(int16_t xin, int16_t yin) { + ICOORD(int32_t xin, int32_t yin) { xcoord = xin; ycoord = yin; } @@ -54,20 +54,20 @@ class ICOORD { bool Serialize(TFile *f) const; /// access function - int16_t x() const { + int32_t x() const { return xcoord; } /// access_function - int16_t y() const { + int32_t y() const { return ycoord; } /// rewrite function - void set_x(int16_t xin) { + void set_x(int32_t xin) { xcoord = xin; // write new value } /// rewrite function - void set_y(int16_t yin) { // value to set + void set_y(int32_t yin) { // value to set ycoord = yin; } @@ -128,15 +128,15 @@ class ICOORD { /// cross product friend int32_t operator*(const ICOORD &, const ICOORD &); /// multiply - friend ICOORD operator*(const ICOORD &, int16_t); + friend ICOORD operator*(const ICOORD &, int32_t); /// multiply - friend ICOORD operator*(int16_t, const ICOORD &); + friend ICOORD operator*(int32_t, const ICOORD &); /// multiply - friend ICOORD &operator*=(ICOORD &, int16_t); + friend ICOORD &operator*=(ICOORD &, int32_t); /// divide - friend ICOORD operator/(const ICOORD &, int16_t); + friend ICOORD operator/(const ICOORD &, int32_t); /// divide - friend ICOORD &operator/=(ICOORD &, int16_t); + friend ICOORD &operator/=(ICOORD &, int32_t); /// rotate ///@param vec by vector void rotate(const FCOORD &vec); @@ -155,8 +155,8 @@ class ICOORD { bool DeSerialize(bool swap, FILE *fp); protected: - int16_t xcoord; ///< x value - int16_t ycoord; ///< y value + int32_t xcoord; ///< x value + int32_t ycoord; ///< y value }; class ICOORDELT : public ELIST_LINK, @@ -171,7 +171,7 @@ class ICOORDELT : public ELIST_LINK, /// constructor ///@param xin x value ///@param yin y value - ICOORDELT(int16_t xin, int16_t yin) { + ICOORDELT(int32_t xin, int32_t yin) { xcoord = xin; ycoord = yin; } @@ -438,7 +438,7 @@ inline int32_t operator*( // cross product inline ICOORD operator*( // scalar multiply const ICOORD &op1, // operands - int16_t scale) { + int32_t scale) { ICOORD result; // output result.xcoord = op1.xcoord * scale; @@ -447,7 +447,7 @@ inline ICOORD operator*( // scalar multiply } inline ICOORD operator*( // scalar multiply - int16_t scale, + int32_t scale, const ICOORD &op1 // operands ) { ICOORD result; // output @@ -465,7 +465,7 @@ inline ICOORD operator*( // scalar multiply inline ICOORD &operator*=( // scalar multiply ICOORD &op1, // operands - int16_t scale) { + int32_t scale) { op1.xcoord *= scale; op1.ycoord *= scale; return op1; @@ -479,7 +479,7 @@ inline ICOORD &operator*=( // scalar multiply inline ICOORD operator/( // scalar divide const ICOORD &op1, // operands - int16_t scale) { + int32_t scale) { ICOORD result; // output result.xcoord = op1.xcoord / scale; @@ -495,7 +495,7 @@ inline ICOORD operator/( // scalar divide inline ICOORD &operator/=( // scalar divide ICOORD &op1, // operands - int16_t scale) { + int32_t scale) { op1.xcoord /= scale; op1.ycoord /= scale; return op1; @@ -509,8 +509,8 @@ inline ICOORD &operator/=( // scalar divide inline void ICOORD::rotate( // rotate by vector const FCOORD &vec) { - auto tmp = static_cast(std::floor(xcoord * vec.x() - ycoord * vec.y() + 0.5f)); - ycoord = static_cast(std::floor(ycoord * vec.x() + xcoord * vec.y() + 0.5f)); + auto tmp = static_cast(std::floor(xcoord * vec.x() - ycoord * vec.y() + 0.5f)); + ycoord = static_cast(std::floor(ycoord * vec.x() + xcoord * vec.y() + 0.5f)); xcoord = tmp; } diff --git a/src/ccstruct/polyblk.cpp b/src/ccstruct/polyblk.cpp index a7125445f5..12c498754d 100644 --- a/src/ccstruct/polyblk.cpp +++ b/src/ccstruct/polyblk.cpp @@ -198,8 +198,8 @@ void POLY_BLOCK::rotate(FCOORD rotation) { pos.set_x(pt->x()); pos.set_y(pt->y()); pos.rotate(rotation); - pt->set_x(static_cast(floor(pos.x() + 0.5))); - pt->set_y(static_cast(floor(pos.y() + 0.5))); + pt->set_x(static_cast(floor(pos.x() + 0.5))); + pt->set_y(static_cast(floor(pos.y() + 0.5))); pts.forward(); } while (!pts.at_first()); compute_bb(); @@ -270,15 +270,12 @@ void POLY_BLOCK::plot(ScrollView *window, int32_t num) { } void POLY_BLOCK::fill(ScrollView *window, ScrollView::Color colour) { - int16_t y; - int16_t width; - PB_LINE_IT *lines; ICOORDELT_IT s_it; - lines = new PB_LINE_IT(this); + std::unique_ptr lines(new PB_LINE_IT(this)); window->Pen(colour); - for (y = this->bounding_box()->bottom(); y <= this->bounding_box()->top(); y++) { + for (auto y = this->bounding_box()->bottom(); y <= this->bounding_box()->top(); y++) { const std::unique_ptr segments(lines->get_line(y)); if (!segments->empty()) { s_it.set_to_list(segments.get()); @@ -286,14 +283,12 @@ void POLY_BLOCK::fill(ScrollView *window, ScrollView::Color colour) { // Note different use of ICOORDELT, x coord is x coord of pixel // at the start of line segment, y coord is length of line segment // Last pixel is start pixel + length. - width = s_it.data()->y(); + auto width = s_it.data()->y(); window->SetCursor(s_it.data()->x(), y); window->DrawTo(s_it.data()->x() + static_cast(width), y); } } } - - delete lines; } #endif @@ -339,7 +334,7 @@ bool POLY_BLOCK::overlap(POLY_BLOCK *other) { return false; } -ICOORDELT_LIST *PB_LINE_IT::get_line(int16_t y) { +ICOORDELT_LIST *PB_LINE_IT::get_line(int32_t y) { ICOORDELT_IT v, r; ICOORDELT_LIST *result; ICOORDELT *x, *current, *previous; @@ -356,7 +351,7 @@ ICOORDELT_LIST *PB_LINE_IT::get_line(int16_t y) { float fx = 0.5f + previous->x() + (current->x() - previous->x()) * (fy - previous->y()) / (current->y() - previous->y()); - x = new ICOORDELT(static_cast(fx), 0); + x = new ICOORDELT(static_cast(fx), 0); r.add_to_end(x); } } diff --git a/src/ccstruct/polyblk.h b/src/ccstruct/polyblk.h index eeb3aa0481..8e46cb9788 100644 --- a/src/ccstruct/polyblk.h +++ b/src/ccstruct/polyblk.h @@ -106,7 +106,7 @@ class PB_LINE_IT { // Each element of the returned list is the start (x) and extent(y) of // a run inside the region. // Delete the returned list after use. - ICOORDELT_LIST *get_line(int16_t y); + ICOORDELT_LIST *get_line(int32_t y); private: POLY_BLOCK *block; diff --git a/src/ccstruct/rect.cpp b/src/ccstruct/rect.cpp index 9948859581..686b6c7fd3 100644 --- a/src/ccstruct/rect.cpp +++ b/src/ccstruct/rect.cpp @@ -83,10 +83,10 @@ void TBOX::rotate_large(const FCOORD &vec) { TBOX TBOX::intersection( // shared area box const TBOX &box) const { - int16_t left; - int16_t bottom; - int16_t right; - int16_t top; + int32_t left; + int32_t bottom; + int32_t right; + int32_t top; if (overlap(box)) { if (box.bot_left.x() > bot_left.x()) { left = box.bot_left.x(); diff --git a/src/ccstruct/rect.h b/src/ccstruct/rect.h index 9917c94c4d..1e0bb24aa5 100644 --- a/src/ccstruct/rect.h +++ b/src/ccstruct/rect.h @@ -50,7 +50,7 @@ class TESS_API TBOX { // bounding box // in the right order. //********************************************************************* TBOX( // constructor - int16_t left, int16_t bottom, int16_t right, int16_t top) + int32_t left, int32_t bottom, int32_t right, int32_t top) : bot_left(left, bottom), top_right(right, top) {} TBOX( // box around FCOORD @@ -64,28 +64,28 @@ class TESS_API TBOX { // bounding box return bot_left == other.bot_left && top_right == other.top_right; } - int16_t top() const { // coord of top + int32_t top() const { // coord of top return top_right.y(); } void set_top(int y) { top_right.set_y(y); } - int16_t bottom() const { // coord of bottom + int32_t bottom() const { // coord of bottom return bot_left.y(); } void set_bottom(int y) { bot_left.set_y(y); } - int16_t left() const { // coord of left + int32_t left() const { // coord of left return bot_left.x(); } void set_left(int x) { bot_left.set_x(x); } - int16_t right() const { // coord of right + int32_t right() const { // coord of right return top_right.x(); } void set_right(int x) { @@ -114,7 +114,7 @@ class TESS_API TBOX { // bounding box return top_right; } - int16_t height() const { // how high is it? + int32_t height() const { // how high is it? if (!null_box()) { return top_right.y() - bot_left.y(); } else { @@ -122,7 +122,7 @@ class TESS_API TBOX { // bounding box } } - int16_t width() const { // how high is it? + int32_t width() const { // how high is it? if (!null_box()) { return top_right.x() - bot_left.x(); } else { @@ -147,22 +147,22 @@ class TESS_API TBOX { // bounding box } void move_bottom_edge( // move one edge - const int16_t y) { // by +/- y + const int32_t y) { // by +/- y bot_left += ICOORD(0, y); } void move_left_edge( // move one edge - const int16_t x) { // by +/- x + const int32_t x) { // by +/- x bot_left += ICOORD(x, 0); } void move_right_edge( // move one edge - const int16_t x) { // by +/- x + const int32_t x) { // by +/- x top_right += ICOORD(x, 0); } void move_top_edge( // move one edge - const int16_t y) { // by +/- y + const int32_t y) { // by +/- y top_right += ICOORD(0, y); } @@ -174,33 +174,33 @@ class TESS_API TBOX { // bounding box void move( // move box const FCOORD vec) { // by float vector - bot_left.set_x(static_cast(std::floor(bot_left.x() + vec.x()))); + bot_left.set_x(static_cast(std::floor(bot_left.x() + vec.x()))); // round left - bot_left.set_y(static_cast(std::floor(bot_left.y() + vec.y()))); + bot_left.set_y(static_cast(std::floor(bot_left.y() + vec.y()))); // round down - top_right.set_x(static_cast(std::ceil(top_right.x() + vec.x()))); + top_right.set_x(static_cast(std::ceil(top_right.x() + vec.x()))); // round right - top_right.set_y(static_cast(std::ceil(top_right.y() + vec.y()))); + top_right.set_y(static_cast(std::ceil(top_right.y() + vec.y()))); // round up } void scale( // scale box const float f) { // by multiplier // round left - bot_left.set_x(static_cast(std::floor(bot_left.x() * f))); + bot_left.set_x(static_cast(std::floor(bot_left.x() * f))); // round down - bot_left.set_y(static_cast(std::floor(bot_left.y() * f))); + bot_left.set_y(static_cast(std::floor(bot_left.y() * f))); // round right - top_right.set_x(static_cast(std::ceil(top_right.x() * f))); + top_right.set_x(static_cast(std::ceil(top_right.x() * f))); // round up - top_right.set_y(static_cast(std::ceil(top_right.y() * f))); + top_right.set_y(static_cast(std::ceil(top_right.y() * f))); } void scale( // scale box const FCOORD vec) { // by float vector - bot_left.set_x(static_cast(std::floor(bot_left.x() * vec.x()))); - bot_left.set_y(static_cast(std::floor(bot_left.y() * vec.y()))); - top_right.set_x(static_cast(std::ceil(top_right.x() * vec.x()))); - top_right.set_y(static_cast(std::ceil(top_right.y() * vec.y()))); + bot_left.set_x(static_cast(std::floor(bot_left.x() * vec.x()))); + bot_left.set_y(static_cast(std::floor(bot_left.y() * vec.y()))); + top_right.set_x(static_cast(std::ceil(top_right.x() * vec.x()))); + top_right.set_y(static_cast(std::ceil(top_right.y() * vec.y()))); } // rotate doesn't enlarge the box - it just rotates the bottom-left @@ -330,9 +330,9 @@ inline TBOX::TBOX( // constructor const FCOORD pt // floating centre ) { bot_left = - ICOORD(static_cast(std::floor(pt.x())), static_cast(std::floor(pt.y()))); + ICOORD(static_cast(std::floor(pt.x())), static_cast(std::floor(pt.y()))); top_right = - ICOORD(static_cast(std::ceil(pt.x())), static_cast(std::ceil(pt.y()))); + ICOORD(static_cast(std::ceil(pt.x())), static_cast(std::ceil(pt.y()))); } /********************************************************************** @@ -416,7 +416,7 @@ inline bool TBOX::x_overlap(const TBOX &box) const { **********************************************************************/ inline bool TBOX::major_x_overlap(const TBOX &box) const { - int16_t overlap = box.width(); + int32_t overlap = box.width(); if (this->left() > box.left()) { overlap -= this->left() - box.left(); } @@ -442,7 +442,7 @@ inline bool TBOX::y_overlap(const TBOX &box) const { **********************************************************************/ inline bool TBOX::major_y_overlap(const TBOX &box) const { - int16_t overlap = box.height(); + int32_t overlap = box.height(); if (this->bottom() > box.bottom()) { overlap -= this->bottom() - box.bottom(); } diff --git a/src/textord/edgblob.cpp b/src/textord/edgblob.cpp index 26b6d22510..1539a13156 100644 --- a/src/textord/edgblob.cpp +++ b/src/textord/edgblob.cpp @@ -77,8 +77,8 @@ OL_BUCKETS::OL_BUCKETS(ICOORD bleft, // corners */ C_OUTLINE_LIST *OL_BUCKETS::operator()( // array access - int16_t x, // image coords - int16_t y) { + int32_t x, // image coords + int32_t y) { return &buckets[(y - bl.y()) / BUCKETSIZE * bxdim + (x - bl.x()) / BUCKETSIZE]; } @@ -122,9 +122,8 @@ int32_t OL_BUCKETS::outline_complexity(C_OUTLINE *outline, // parent outline int32_t max_count, // max output int16_t depth // recurion depth ) { - int16_t xmin, xmax; // coord limits - int16_t ymin, ymax; - int16_t xindex, yindex; // current bucket + int32_t xmin, xmax; // coord limits + int32_t ymin, ymax; C_OUTLINE *child; // current child int32_t child_count; // no of children int32_t grandchild_count; // no of grandchildren @@ -141,8 +140,8 @@ int32_t OL_BUCKETS::outline_complexity(C_OUTLINE *outline, // parent outline return max_count + depth; } - for (yindex = ymin; yindex <= ymax; yindex++) { - for (xindex = xmin; xindex <= xmax; xindex++) { + for (auto yindex = ymin; yindex <= ymax; yindex++) { + for (auto xindex = xmin; xindex <= xmax; xindex++) { child_it.set_to_list(&buckets[yindex * bxdim + xindex]); if (child_it.empty()) { continue; @@ -198,9 +197,8 @@ int32_t OL_BUCKETS::count_children( // recursive count int32_t max_count // max output ) { bool parent_box; // could it be boxy - int16_t xmin, xmax; // coord limits - int16_t ymin, ymax; - int16_t xindex, yindex; // current bucket + int32_t xmin, xmax; // coord limits + int32_t ymin, ymax; C_OUTLINE *child; // current child int32_t child_count; // no of children int32_t grandchild_count; // no of grandchildren @@ -221,8 +219,8 @@ int32_t OL_BUCKETS::count_children( // recursive count parent_area = 0; max_parent_area = 0; parent_box = true; - for (yindex = ymin; yindex <= ymax; yindex++) { - for (xindex = xmin; xindex <= xmax; xindex++) { + for (auto yindex = ymin; yindex <= ymax; yindex++) { + for (auto xindex = xmin; xindex <= xmax; xindex++) { child_it.set_to_list(&buckets[yindex * bxdim + xindex]); if (child_it.empty()) { continue; @@ -321,9 +319,8 @@ void OL_BUCKETS::extract_children( // recursive count C_OUTLINE *outline, // parent outline C_OUTLINE_IT *it // destination iterator ) { - int16_t xmin, xmax; // coord limits - int16_t ymin, ymax; - int16_t xindex, yindex; // current bucket + int32_t xmin, xmax; // coord limits + int32_t ymin, ymax; TBOX olbox; C_OUTLINE_IT child_it; // search iterator @@ -332,8 +329,8 @@ void OL_BUCKETS::extract_children( // recursive count xmax = (olbox.right() - bl.x()) / BUCKETSIZE; ymin = (olbox.bottom() - bl.y()) / BUCKETSIZE; ymax = (olbox.top() - bl.y()) / BUCKETSIZE; - for (yindex = ymin; yindex <= ymax; yindex++) { - for (xindex = xmin; xindex <= xmax; xindex++) { + for (auto yindex = ymin; yindex <= ymax; yindex++) { + for (auto xindex = xmin; xindex <= xmax; xindex++) { child_it.set_to_list(&buckets[yindex * bxdim + xindex]); for (child_it.mark_cycle_pt(); !child_it.cycled_list(); child_it.forward()) { diff --git a/src/textord/edgblob.h b/src/textord/edgblob.h index c3db12be08..4fa58e5ad8 100644 --- a/src/textord/edgblob.h +++ b/src/textord/edgblob.h @@ -34,8 +34,8 @@ class OL_BUCKETS { ICOORD tright); C_OUTLINE_LIST *operator()( // array access - int16_t x, // image coords - int16_t y); + int32_t x, // image coords + int32_t y); // first non-empty bucket C_OUTLINE_LIST *start_scan(); // next non-empty bucket diff --git a/src/textord/scanedg.cpp b/src/textord/scanedg.cpp index 6c18bdd76c..6be31668b2 100644 --- a/src/textord/scanedg.cpp +++ b/src/textord/scanedg.cpp @@ -44,11 +44,11 @@ static void free_crackedges(CRACKEDGE *start); static void join_edges(CRACKEDGE *edge1, CRACKEDGE *edge2, CRACKEDGE **free_cracks, C_OUTLINE_IT *outline_it); -static void line_edges(int16_t x, int16_t y, int16_t xext, uint8_t uppercolour, uint8_t *bwpos, +static void line_edges(int32_t x, int32_t y, int32_t xext, uint8_t uppercolour, uint8_t *bwpos, CRACKEDGE **prevline, CRACKEDGE **free_cracks, C_OUTLINE_IT *outline_it); static void make_margins(PDBLK *block, BLOCK_LINE_IT *line_it, uint8_t *pixels, uint8_t margin, - int16_t left, int16_t right, int16_t y); + int32_t left, int32_t right, int32_t y); static CRACKEDGE *h_edge(int sign, CRACKEDGE *join, CrackPos *pos); static CRACKEDGE *v_edge(int sign, CRACKEDGE *join, CrackPos *pos); @@ -114,14 +114,11 @@ static void make_margins( // get a line BLOCK_LINE_IT *line_it, // for old style uint8_t *pixels, // pixels to strip uint8_t margin, // white-out pixel - int16_t left, // block edges - int16_t right, - int16_t y // line coord + int32_t left, // block edges + int32_t right, + int32_t y // line coord ) { ICOORDELT_IT seg_it; - int32_t start; // of segment - int16_t xext; // of segment - int xindex; // index to pixel if (block->poly_block() != nullptr) { std::unique_ptr lines(new PB_LINE_IT(block->poly_block())); @@ -129,9 +126,9 @@ static void make_margins( // get a line if (!segments->empty()) { seg_it.set_to_list(segments.get()); seg_it.mark_cycle_pt(); - start = seg_it.data()->x(); - xext = seg_it.data()->y(); - for (xindex = left; xindex < right; xindex++) { + auto start = seg_it.data()->x(); + auto xext = seg_it.data()->y(); + for (auto xindex = left; xindex < right; xindex++) { if (xindex >= start && !seg_it.cycled_list()) { xindex = start + xext - 1; seg_it.forward(); @@ -142,16 +139,17 @@ static void make_margins( // get a line } } } else { - for (xindex = left; xindex < right; xindex++) { + for (auto xindex = left; xindex < right; xindex++) { pixels[xindex - left] = margin; } } } else { - start = line_it->get_line(y, xext); - for (xindex = left; xindex < start; xindex++) { + int32_t xext; // of segment + auto start = line_it->get_line(y, xext); + for (auto xindex = left; xindex < start; xindex++) { pixels[xindex - left] = margin; } - for (xindex = start + xext; xindex < right; xindex++) { + for (auto xindex = start + xext; xindex < right; xindex++) { pixels[xindex - left] = margin; } } @@ -164,9 +162,9 @@ static void make_margins( // get a line * When edges close into loops, send them for approximation. **********************************************************************/ -static void line_edges(int16_t x, // coord of line start - int16_t y, // coord of line - int16_t xext, // width of line +static void line_edges(int32_t x, // coord of line start + int32_t y, // coord of line + int32_t xext, // width of line uint8_t uppercolour, // start of prev line uint8_t *bwpos, // thresholded line CRACKEDGE **prevline, // edges in progress diff --git a/src/textord/tordmain.cpp b/src/textord/tordmain.cpp index 3e44fead2b..69812680b7 100644 --- a/src/textord/tordmain.cpp +++ b/src/textord/tordmain.cpp @@ -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()) {