23 #include "allheaders.h"
29 #define FLIP_COLOUR(pix) (1-(pix))
39 C_OUTLINE_IT* outline_it) {
44 int width = pixGetWidth(t_pix);
45 int height = pixGetHeight(t_pix);
46 int wpl = pixGetWpl(t_pix);
48 std::unique_ptr<CRACKEDGE*[]> ptrline(
new CRACKEDGE*[width + 1]);
54 int block_width = tright.
x() - bleft.
x();
55 for (
int x = block_width; x >= 0; x--)
58 std::unique_ptr<uint8_t[]> bwline(
new uint8_t[width]);
62 for (
int y = tright.
y() - 1; y >= bleft.
y() - 1; y--) {
63 if (y >= bleft.
y() && y < tright.
y()) {
65 l_uint32* line = pixGetData(t_pix) + wpl * (height - 1 - y);
66 for (
int x = 0; x < block_width; ++x) {
67 bwline[x] = GET_DATA_BIT(line, x + bleft.
x()) ^ 1;
69 make_margins(block, &line_it, bwline.get(), margin, bleft.
x(), tright.
x(), y);
71 memset(bwline.get(), margin, block_width *
sizeof(bwline[0]));
74 margin, bwline.get(), ptrline.get(), &free_cracks, outline_it);
103 const std::unique_ptr< ICOORDELT_LIST> segments(
105 if (!segments->empty ()) {
106 seg_it.set_to_list(segments.get());
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;
127 start = line_it->
get_line (y, xext);
128 for (xindex = left; xindex < start; xindex++)
129 pixels[xindex - left] = margin;
130 for (xindex = start + xext; xindex < right; xindex++)
131 pixels[xindex - left] = margin;
149 C_OUTLINE_IT* outline_it) {
150 CrackPos pos = {free_cracks, x, y };
157 prevcolour = uppercolour;
161 for (; pos.
x < xmax; pos.
x++, prevline++) {
162 const int colour = *bwpos++;
163 if (*prevline !=
nullptr) {
167 if (colour == prevcolour) {
168 if (colour == uppercolour) {
170 join_edges(current, *prevline, free_cracks, outline_it);
174 current =
h_edge(uppercolour - colour, *prevline, &pos);
178 if (colour == uppercolour)
179 *prevline =
v_edge(colour - prevcolour, *prevline, &pos);
182 join_edges(current, *prevline, free_cracks, outline_it);
183 current =
h_edge(uppercolour - colour,
nullptr, &pos);
184 *prevline =
v_edge(colour - prevcolour, current, &pos);
186 newcurrent =
h_edge(uppercolour - colour, *prevline, &pos);
187 *prevline =
v_edge(colour - prevcolour, current, &pos);
188 current = newcurrent;
193 if (colour != prevcolour) {
194 *prevline = current =
v_edge(colour - prevcolour, current, &pos);
197 if (colour != uppercolour)
198 current =
h_edge(uppercolour - colour, current, &pos);
203 if (current !=
nullptr) {
205 if (*prevline !=
nullptr) {
206 join_edges(current, *prevline, free_cracks, outline_it);
212 }
else if (*prevline !=
nullptr) {
249 if (join ==
nullptr) {
254 && newpt->
pos.
y() == join->
pos.
y()) {
300 if (join ==
nullptr) {
331 C_OUTLINE_IT* outline_it) {
339 if (edge1->
next == edge2) {
344 *free_cracks = edge1;
365 for (current = start; current !=
nullptr; current = next) {
366 next = current->
next;
void complete_edge(CRACKEDGE *start, C_OUTLINE_IT *outline_it)
CRACKEDGE * h_edge(int sign, CRACKEDGE *join, CrackPos *pos)
void free_crackedges(CRACKEDGE *start)
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)
void block_edges(Pix *t_pix, PDBLK *block, C_OUTLINE_IT *outline_it)
void join_edges(CRACKEDGE *edge1, CRACKEDGE *edge2, CRACKEDGE **free_cracks, C_OUTLINE_IT *outline_it)
CRACKEDGE * v_edge(int sign, CRACKEDGE *join, CrackPos *pos)
void line_edges(int16_t x, int16_t y, int16_t xext, uint8_t uppercolour, uint8_t *bwpos, CRACKEDGE **prevline, CRACKEDGE **free_cracks, C_OUTLINE_IT *outline_it)
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
POLY_BLOCK * poly_block() const
int16_t get_line(int16_t y, int16_t &xext)
void set_x(int16_t xin)
rewrite function
int16_t y() const
access_function
void set_y(int16_t yin)
rewrite function
int16_t x() const
access function