24 #include "allheaders.h" 30 #define FLIP_COLOUR(pix) (1-(pix)) 40 C_OUTLINE_IT* outline_it) {
45 int width = pixGetWidth(t_pix);
46 int height = pixGetHeight(t_pix);
47 int wpl = pixGetWpl(t_pix);
53 int block_width = tright.
x() - bleft.
x();
54 for (
int x = block_width; x >= 0; x--)
61 for (
int y = tright.
y() - 1; y >= bleft.
y() - 1; y--) {
62 if (y >= bleft.
y() && y < tright.
y()) {
64 l_uint32* line = pixGetData(t_pix) + wpl * (height - 1 - y);
65 for (
int x = 0; x < block_width; ++x) {
66 bwline[x] = GET_DATA_BIT(line, x + bleft.
x()) ^ 1;
68 make_margins(block, &line_it, bwline, margin, bleft.
x(), tright.
x(), y);
70 memset(bwline, margin, block_width *
sizeof(bwline[0]));
73 margin, bwline, ptrline, &free_cracks, outline_it);
105 const std::unique_ptr< ICOORDELT_LIST> segments(
107 if (!segments->empty ()) {
108 seg_it.set_to_list(segments.get());
109 seg_it.mark_cycle_pt ();
110 start = seg_it.data ()->x ();
111 xext = seg_it.data ()->y ();
112 for (xindex = left; xindex < right; xindex++) {
113 if (xindex >= start && !seg_it.cycled_list ()) {
114 xindex = start + xext - 1;
116 start = seg_it.data ()->x ();
117 xext = seg_it.data ()->y ();
120 pixels[xindex - left] = margin;
124 for (xindex = left; xindex < right; xindex++)
125 pixels[xindex - left] = margin;
130 start = line_it->
get_line (y, xext);
131 for (xindex = left; xindex < start; xindex++)
132 pixels[xindex - left] = margin;
133 for (xindex = start + xext; xindex < right; xindex++)
134 pixels[xindex - left] = margin;
152 C_OUTLINE_IT* outline_it) {
153 CrackPos pos = {free_cracks, x, y };
161 prevcolour = uppercolour;
165 for (; pos.
x < xmax; pos.
x++, prevline++) {
167 if (*prevline != NULL) {
171 if (colour == prevcolour) {
172 if (colour == uppercolour) {
174 join_edges(current, *prevline, free_cracks, outline_it);
178 current =
h_edge(uppercolour - colour, *prevline, &pos);
182 if (colour == uppercolour)
183 *prevline =
v_edge(colour - prevcolour, *prevline, &pos);
186 join_edges(current, *prevline, free_cracks, outline_it);
187 current =
h_edge(uppercolour - colour, NULL, &pos);
188 *prevline =
v_edge(colour - prevcolour, current, &pos);
190 newcurrent =
h_edge(uppercolour - colour, *prevline, &pos);
191 *prevline =
v_edge(colour - prevcolour, current, &pos);
192 current = newcurrent;
197 if (colour != prevcolour) {
198 *prevline = current =
v_edge(colour - prevcolour, current, &pos);
201 if (colour != uppercolour)
202 current =
h_edge(uppercolour - colour, current, &pos);
207 if (current != NULL) {
209 if (*prevline != NULL) {
210 join_edges(current, *prevline, free_cracks, outline_it);
216 }
else if (*prevline != NULL) {
258 && newpt->
pos.
y() == join->
pos.
y()) {
335 C_OUTLINE_IT* outline_it) {
343 if (edge1->
next == edge2) {
348 *free_cracks = edge1;
369 for (current = start; current != NULL; current = next) {
370 next = current->
next;
CRACKEDGE * v_edge(int sign, CRACKEDGE *join, CrackPos *pos)
void block_edges(Pix *t_pix, PDBLK *block, C_OUTLINE_IT *outline_it)
void set_y(inT16 yin)
rewrite function
void make_margins(PDBLK *block, BLOCK_LINE_IT *line_it, uinT8 *pixels, uinT8 margin, inT16 left, inT16 right, inT16 y)
void complete_edge(CRACKEDGE *start, C_OUTLINE_IT *outline_it)
inT16 x() const
access function
void set_x(inT16 xin)
rewrite function
inT16 get_line(inT16 y, inT16 &xext)
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
CRACKEDGE * h_edge(int sign, CRACKEDGE *join, CrackPos *pos)
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 join_edges(CRACKEDGE *edge1, CRACKEDGE *edge2, CRACKEDGE **free_cracks, C_OUTLINE_IT *outline_it)
POLY_BLOCK * poly_block() const
inT16 y() const
access_function
LIST join(LIST list1, LIST list2)
ICOORDELT_LIST * get_line(inT16 y)