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 };
158 prevcolour = uppercolour;
162 for (; pos.
x < xmax; pos.
x++, prevline++) {
164 if (*prevline !=
nullptr) {
168 if (colour == prevcolour) {
169 if (colour == uppercolour) {
171 join_edges(current, *prevline, free_cracks, outline_it);
175 current =
h_edge(uppercolour - colour, *prevline, &pos);
179 if (colour == uppercolour)
180 *prevline =
v_edge(colour - prevcolour, *prevline, &pos);
183 join_edges(current, *prevline, free_cracks, outline_it);
184 current =
h_edge(uppercolour - colour,
nullptr, &pos);
185 *prevline =
v_edge(colour - prevcolour, current, &pos);
187 newcurrent =
h_edge(uppercolour - colour, *prevline, &pos);
188 *prevline =
v_edge(colour - prevcolour, current, &pos);
189 current = newcurrent;
194 if (colour != prevcolour) {
195 *prevline = current =
v_edge(colour - prevcolour, current, &pos);
198 if (colour != uppercolour)
199 current =
h_edge(uppercolour - colour, current, &pos);
204 if (current !=
nullptr) {
206 if (*prevline !=
nullptr) {
207 join_edges(current, *prevline, free_cracks, outline_it);
213 }
else if (*prevline !=
nullptr) {
250 if (
join ==
nullptr) {
255 && newpt->
pos.
y() ==
join->pos.y()) {
301 if (
join ==
nullptr) {
332 C_OUTLINE_IT* outline_it) {
340 if (edge1->
next == edge2) {
345 *free_cracks = edge1;
366 for (current = start; current !=
nullptr; current = next) {
367 next = current->
next;
void free_crackedges(CRACKEDGE *start)
void set_x(int16_t xin)
rewrite function
CRACKEDGE * v_edge(int sign, CRACKEDGE *join, CrackPos *pos)
void complete_edge(CRACKEDGE *start, C_OUTLINE_IT *outline_it)
int16_t y() const
access_function
void join_edges(CRACKEDGE *edge1, CRACKEDGE *edge2, CRACKEDGE **free_cracks, C_OUTLINE_IT *outline_it)
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 make_margins(PDBLK *block, BLOCK_LINE_IT *line_it, uint8_t *pixels, uint8_t margin, int16_t left, int16_t right, int16_t y)
CRACKEDGE * h_edge(int sign, CRACKEDGE *join, CrackPos *pos)
int16_t get_line(int16_t y, int16_t &xext)
int16_t x() const
access function
ICOORDELT_LIST * get_line(int16_t y)
LIST join(LIST list1, LIST list2)
POLY_BLOCK * poly_block() const
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
void set_y(int16_t yin)
rewrite function
void block_edges(Pix *t_pix, PDBLK *block, C_OUTLINE_IT *outline_it)