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(lines->
get_line (y));
106 if (!segments->empty ()) {
107 seg_it.set_to_list (segments.get());
108 seg_it.mark_cycle_pt ();
109 start = seg_it.data ()->x ();
110 xext = seg_it.data ()->y ();
111 for (xindex = left; xindex < right; xindex++) {
112 if (xindex >= start && !seg_it.cycled_list ()) {
113 xindex = start + xext - 1;
115 start = seg_it.data ()->x ();
116 xext = seg_it.data ()->y ();
119 pixels[xindex - left] = margin;
123 for (xindex = left; xindex < right; xindex++)
124 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 line_edges(inT16 x, inT16 y, inT16 xext, uinT8 uppercolour, uinT8 *bwpos, CRACKEDGE **prevline, CRACKEDGE **free_cracks, C_OUTLINE_IT *outline_it)
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
void set_x(inT16 xin)
rewrite function
inT16 x() const
access function
CRACKEDGE * v_edge(int sign, CRACKEDGE *join, CrackPos *pos)
ICOORDELT_LIST * get_line(inT16 y)
inT16 y() const
access_function
void make_margins(PDBLK *block, BLOCK_LINE_IT *line_it, uinT8 *pixels, uinT8 margin, inT16 left, inT16 right, inT16 y)
CRACKEDGE * h_edge(int sign, CRACKEDGE *join, CrackPos *pos)
void join_edges(CRACKEDGE *edge1, CRACKEDGE *edge2, CRACKEDGE **free_cracks, C_OUTLINE_IT *outline_it)
POLY_BLOCK * poly_block() const
void block_edges(Pix *t_pix, PDBLK *block, C_OUTLINE_IT *outline_it)
void free_crackedges(CRACKEDGE *start)
LIST join(LIST list1, LIST list2)
void complete_edge(CRACKEDGE *start, C_OUTLINE_IT *outline_it)
inT16 get_line(inT16 y, inT16 &xext)
void set_y(inT16 yin)
rewrite function