Skip to content

Commit 160d48c

Browse files
authored
Merge pull request #21 from EmbroidePy/0.1.14
PMV Tweaks
2 parents 76720ab + 77d8f7a commit 160d48c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

core/src/main/java/org/embroideryio/embroideryio/PmvReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void read_pmv_stitches(EmbReader reader) throws IOException {
2525
x = -(64 - x); // 6 bit signed number.
2626
}
2727
x *= 2.5;
28-
y *= 2.5;
28+
y -= 2.5;
2929
int dx = x;
3030
pattern.stitchAbs(px + x, y);
3131
px += dx;

core/src/main/java/org/embroideryio/embroideryio/PmvWriter.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void write() throws IOException {
7272
}
7373
int data = pattern.getData(i) & COMMAND_MASK;
7474
float x = pattern.getX(i);
75-
float y = pattern.getY(i);
75+
float y = -pattern.getY(i);
7676
x *= scale_x;
7777
y -= center_y;
7878
y *= scale_y;
@@ -82,10 +82,10 @@ public void write() throws IOException {
8282
if (data != STITCH && data != JUMP) {
8383
continue;
8484
}
85-
if (int_x > int_max_x) {
85+
if (xx > int_max_x) {
8686
int_max_x = int_x;
8787
}
88-
if (int_x < int_min_x) {
88+
if (xx < int_min_x) {
8989
int_min_x = int_x;
9090
}
9191
if (int_y > int_max_y) {
@@ -119,7 +119,7 @@ public void write() throws IOException {
119119
write_length_lookup_table(length_range);
120120
int width_range = int_max_y - int_min_y;
121121
write_width_lookup_table(width_range);
122-
writeInt16LE(0x12);
122+
writeInt16LE(0x12); // (250,1000)
123123
write(new byte[]{
124124
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
125125
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@@ -145,18 +145,18 @@ private void write_length_lookup_table(int length_range) throws IOException {
145145
}
146146

147147
private void write_width_lookup_table(int width_range) throws IOException {
148-
int pos = width_range / 2;
149-
writeInt8(pos);
150148
if (width_range == 0) {
149+
writeInt8(0);
151150
writeInt8(1);
152151
writeInt16LE(8192);
153152
writeInt16LE(1000);
154153
return;
155154
}
156155
int steps = 15;
157-
writeInt8(steps);
158156
double second_max = 28000.0 / ((float) width_range);
159157
double second_step = second_max / ((float) steps - 1);
158+
writeInt8(steps-1);
159+
writeInt8(steps);
160160
for (int i = 0; i < steps; i++) {
161161
int width_at_step = 50 * i;
162162
int other_at_step = (int) Math.rint(second_step * i);

0 commit comments

Comments
 (0)