22 #include "allheaders.h" 28 #define FLIP_COLOUR(pix) (1-(pix)) 38 C_OUTLINE_IT* outline_it) {
43 int width = pixGetWidth(t_pix);
44 int height = pixGetHeight(t_pix);
45 int wpl = pixGetWpl(t_pix);
51 int block_width = tright.
x() - bleft.
x();
52 for (
int x = block_width; x >= 0; x--)
59 for (
int y = tright.
y() - 1; y >= bleft.
y() - 1; y--) {
60 if (y >= bleft.
y() && y < tright.
y()) {
62 l_uint32* line = pixGetData(t_pix) + wpl * (height - 1 - y);
63 for (
int x = 0; x < block_width; ++x) {
64 bwline[x] = GET_DATA_BIT(line, x + bleft.
x()) ^ 1;
66 make_margins(block, &line_it, bwline, margin, bleft.
x(), tright.
x(), y);
68 memset(bwline, margin, block_width *
sizeof(bwline[0]));
71 margin, bwline, ptrline, &free_cracks, outline_it);
96 ICOORDELT_LIST *segments;
105 if (!segments->empty ()) {
106 seg_it.set_to_list (segments);
107 seg_it.mark_cycle_pt ();
108 start = seg_it.data ()->x ();
109 xext = seg_it.data ()->y ();
110 for (xindex = left; xindex < right; xindex++) {
111 if (xindex >= start && !seg_it.cycled_list ()) {
112 xindex = start + xext - 1;
114 start = seg_it.data ()->x ();
115 xext = seg_it.data ()->y ();
118 pixels[xindex - left] = margin;
122 for (xindex = left; xindex < right; xindex++)
123 pixels[xindex - left] = margin;
129 start = line_it->
get_line (y, xext);
130 for (xindex = left; xindex < start; xindex++)
131 pixels[xindex - left] = margin;
132 for (xindex = start + xext; xindex < right; xindex++)
133 pixels[xindex - left] = margin;
151 C_OUTLINE_IT* outline_it) {
152 CrackPos pos = {free_cracks, x, y };
160 prevcolour = uppercolour;
164 for (; pos.
x < xmax; pos.
x++, prevline++) {
166 if (*prevline != NULL) {
170 if (colour == prevcolour) {
171 if (colour == uppercolour) {
173 join_edges(current, *prevline, free_cracks, outline_it);
177 current =
h_edge(uppercolour - colour, *prevline, &pos);
181 if (colour == uppercolour)
182 *prevline =
v_edge(colour - prevcolour, *prevline, &pos);
185 join_edges(current, *prevline, free_cracks, outline_it);
186 current =
h_edge(uppercolour - colour, NULL, &pos);
187 *prevline =
v_edge(colour - prevcolour, current, &pos);
189 newcurrent =
h_edge(uppercolour - colour, *prevline, &pos);
190 *prevline =
v_edge(colour - prevcolour, current, &pos);
191 current = newcurrent;
196 if (colour != prevcolour) {
197 *prevline = current =
v_edge(colour - prevcolour, current, &pos);
200 if (colour != uppercolour)
201 current =
h_edge(uppercolour - colour, current, &pos);
206 if (current != NULL) {
208 if (*prevline != NULL) {
209 join_edges(current, *prevline, free_cracks, outline_it);
215 }
else if (*prevline != NULL) {
257 && newpt->
pos.
y() ==
join->pos.y()) {
334 C_OUTLINE_IT* outline_it) {
342 if (edge1->
next == edge2) {
347 *free_cracks = edge1;
368 for (current = start; current != NULL; current = next) {
369 next = current->
next;
void complete_edge(CRACKEDGE *start, C_OUTLINE_IT *outline_it)
void join_edges(CRACKEDGE *edge1, CRACKEDGE *edge2, CRACKEDGE **free_cracks, C_OUTLINE_IT *outline_it)
void make_margins(PDBLK *block, BLOCK_LINE_IT *line_it, uinT8 *pixels, uinT8 margin, inT16 left, inT16 right, inT16 y)
LIST join(LIST list1, LIST list2)
CRACKEDGE * v_edge(int sign, CRACKEDGE *join, CrackPos *pos)
void block_edges(Pix *t_pix, PDBLK *block, C_OUTLINE_IT *outline_it)
inT16 get_line(inT16 y, inT16 &xext)
POLY_BLOCK * poly_block() const
ICOORDELT_LIST * get_line(inT16 y)
inT16 x() const
access function
void free_crackedges(CRACKEDGE *start)
void line_edges(inT16 x, inT16 y, inT16 xext, uinT8 uppercolour, uinT8 *bwpos, CRACKEDGE **prevline, CRACKEDGE **free_cracks, C_OUTLINE_IT *outline_it)
void set_y(inT16 yin)
rewrite function
void set_x(inT16 xin)
rewrite function
CRACKEDGE * h_edge(int sign, CRACKEDGE *join, CrackPos *pos)
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
inT16 y() const
access_function