Fix jumpstitch output I noticed that your thumbnailer shows jump stitches yielding some ugly thread lines in some cases. I have attached a patch which solves this problem. Feel free to use it, modify it, whatever. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
diff --git a/cairo.c b/cairo.c index c7d6565..881b144 100644 --- a/cairo.c +++ b/cairo.c
@@ -35,7 +35,8 @@ for (i = 1; i < block->nr_stitches; i++) { ++stitch; - cairo_line_to(cr, X(stitch), Y(stitch)); + if(!stitch->jumpstitch) cairo_line_to(cr, X(stitch), Y(stitch)); + else cairo_move_to(cr, X(stitch), Y(stitch)); } cairo_set_line_width(cr, scale * density); cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
diff --git a/pes.c b/pes.c index d0e858c..18f90a8 100644 --- a/pes.c +++ b/pes.c
@@ -169,7 +169,7 @@ return block; } -static int add_stitch(struct pes *pes, int x, int y) +static int add_stitch(struct pes *pes, int x, int y, int jumpstitch) { struct pes_block *block = pes->last; struct stitch *stitch = block->stitch; @@ -195,6 +195,7 @@ } stitch[nr_stitches].x = x; stitch[nr_stitches].y = y; + stitch[nr_stitches].jumpstitch = jumpstitch; block->nr_stitches = nr_stitches+1; return 0; } @@ -213,7 +214,7 @@ block = new_block(pes); while (p < end) { - int val1 = p[0], val2 = p[1]; + int val1 = p[0], val2 = p[1], jumpstitch = 0; p += 2; if (val1 == 255 && !val2) return 0; @@ -234,6 +235,7 @@ if (val1 & 2048) val1 -= 4096; val2 = *p++; + jumpstitch = 1; } else { if (val1 & 64) val1 -= 128; @@ -255,7 +257,7 @@ oldx = val1; oldy = val2; - if (add_stitch(pes, val1, val2)) + if (add_stitch(pes, val1, val2, jumpstitch)) return -1; } return 0;
diff --git a/pes.h b/pes.h index 97578a4..b132773 100644 --- a/pes.h +++ b/pes.h
@@ -12,7 +12,7 @@ }; struct stitch { - int x, y; + int x, y, jumpstitch; }; struct pes_block {