예제 #1
0
/*! Writes the data from \a pattern to a file with the given \a fileName.
 *  Returns \c true if successful, otherwise returns \c false. */
int writePec(EmbPattern* pattern, const char* fileName)
{
    EmbFile* file = 0;

    if(!embStitchList_count(pattern->stitchList))
    {
        embLog_error("format-pec.c writePec(), pattern contains no stitches\n");
        return 0;
    }

    /* Check for an END stitch and add one if it is not present */
    if(pattern->lastStitch->stitch.flags != END)
        embPattern_addStitchRel(pattern, 0, 0, END, 1);

    file = embFile_open(fileName, "wb");
    if(!file)
    {
        embLog_error("format-pec.c writePec(), cannot open %s for writing\n", fileName);
        return 0;
    }

    embPattern_flipVertical(pattern); /* TODO: There needs to be a matching flipVertical() call after the write to ensure multiple writes from the same pattern work properly */
    embPattern_fixColorCount(pattern);
    embPattern_correctForMaxStitchLength(pattern,12.7, 204.7);
    embPattern_scale(pattern, 10.0);

    binaryWriteBytes(file, "#PEC0001", 8);

    writePecStitches(pattern, file, fileName);

    embFile_close(file);
    return 1;
}
예제 #2
0
/*! Writes the data from \a pattern to a file with the given \a fileName.
 *  Returns \c true if successful, otherwise returns \c false. */
int writeT01(EmbPattern* pattern, const char* fileName)
{
	EmbRect boundingRect;
	EmbFile* file = 0;
	int xx, yy, dx, dy, flags;
	int co = 1, st = 0;
	int ax, ay, mx, my;
	EmbStitchList* pointer = 0;
	
	if (!embStitchList_count(pattern->stitchList))
	{
		embLog_error("format-t01.c writeDst(), pattern contains no stitches\n");
		return 0;
	}

	/* Check for an END stitch and add one if it is not present */
	if (pattern->lastStitch->stitch.flags != END)
		embPattern_addStitchRel(pattern, 0, 0, END, 1);

	file = embFile_open(fileName, "wb");
	if (!file)
	{
		embLog_error("format-t01.c writet01(), cannot open %s for writing\n", fileName);
		return 0;
	}

	embPattern_correctForMaxStitchLength(pattern, 12.1, 12.1);

	xx = yy = 0;
	co = 1;
	co = embThreadList_count(pattern->threadList);
	st = 0;
	st = embStitchList_count(pattern->stitchList);
	flags = NORMAL;
	boundingRect = embPattern_calcBoundingBox(pattern);
	ax = ay = mx = my = 0;
	xx = yy = 0;
	pointer = pattern->stitchList;
	while (pointer)
	{
		/* convert from mm to 0.1mm for file format */
		dx = roundDouble(pointer->stitch.xx * 10.0) - xx;
		dy = roundDouble(pointer->stitch.yy * 10.0) - yy;
		xx = roundDouble(pointer->stitch.xx * 10.0);
		yy = roundDouble(pointer->stitch.yy * 10.0);
		flags = pointer->stitch.flags;
		encode_record(file, dx, dy, flags);
		pointer = pointer->next;
	}
	embFile_close(file);
	return 1;
}
예제 #3
0
/*! Writes the data from \a pattern to a file with the given \a fileName.
 *  Returns \c true if successful, otherwise returns \c false. */
int writeMit(EmbPattern* pattern, const char* fileName)
{
	EmbFile* file = 0;
	EmbStitchList* pointer = 0;
	double xx = 0, yy = 0, dx = 0, dy = 0;
	int flags = 0;

    if(!pattern) { embLog_error("format-mit.c writeMit(), pattern argument is null\n"); return 0; }
    if(!fileName) { embLog_error("format-mit.c writeMit(), fileName argument is null\n"); return 0; }

    if(!embStitchList_count(pattern->stitchList))
    {
        embLog_error("format-mit.c writeMit(), pattern contains no stitches\n");
        return 0;
    }

    /* Check for an END stitch and add one if it is not present */
	if (pattern->lastStitch->stitch.flags != END)
	{
		embPattern_addStitchRel(pattern, 0, 0, END, 1);
	}
	file = embFile_open(fileName, "wb");
	if (!file)
	{
		embLog_error("format-mit.c writeMit(), cannot open %s for writing\n", fileName);
		return 0;
	}
	embPattern_correctForMaxStitchLength(pattern, 0x1F, 0x1F);
	xx = yy = 0;
	pointer = pattern->stitchList;
	while (pointer)
	{
		dx = pointer->stitch.xx - xx;
		dy = pointer->stitch.yy - yy;
		xx = pointer->stitch.xx;
		yy = pointer->stitch.yy;
		flags = pointer->stitch.flags;
		embFile_putc(mitEncodeStitch(dx), file);
		embFile_putc(mitEncodeStitch(dy), file);
		pointer = pointer->next;
	}
	embFile_close(file);
    return 1;
}
예제 #4
0
int writeXxx(EmbPattern* pattern, const char* fileName)
{
    FILE* file = 0;
    int i;
    EmbRect rect;
    int endOfStitches;
    EmbThreadList* colors;
    int curColor = 0;

    if(!pattern) { embLog_error("format-xxx.c writeXxx(), pattern argument is null\n"); return 0; }
    if(!fileName) { embLog_error("format-xxx.c writeXxx(), fileName argument is null\n"); return 0; }

    embPattern_correctForMaxStitchLength(pattern, 124, 127);
    file = fopen(fileName, "wb");
    if(!file)
    {
        embLog_error("format-xxx.c writeXxx(), cannot open %s for writing\n", fileName);
        return 0;
    }
    for(i = 0; i < 0x17; i++)
    {
        binaryWriteByte(file, 0x00);
    }
    binaryWriteUInt(file, (unsigned int) embStitchList_count(pattern->stitchList));
    for(i = 0; i < 0x0C; i++)
    {
        binaryWriteByte(file, 0x00);
    }
    binaryWriteUShort(file, (unsigned short)embThreadList_count(pattern->threadList));
    binaryWriteShort(file, 0x0000);

    rect = embPattern_calcBoundingBox(pattern);
    binaryWriteShort(file, (short)(embRect_width(rect) * 10.0));
    binaryWriteShort(file, (short)(embRect_height(rect) * 10.0));

    binaryWriteShort(file, (short)(embRect_width(rect) / 2.0 * 10));  /*TODO: xEnd from start point x=0 */
    binaryWriteShort(file, (short)(embRect_height(rect) / 2.0 * 10)); /*TODO: yEnd from start point y=0 */
    binaryWriteShort(file, (short)(embRect_width(rect)/2.0 * 10));    /*TODO: left from start x = 0     */
    binaryWriteShort(file, (short)(embRect_height(rect)/2.0 * 10));   /*TODO: bottom from start y = 0   */
    for(i = 0; i < 0xC5; i++)
    {
        binaryWriteByte(file, 0x00);
    }
    binaryWriteInt(file, 0x0000); /* place holder for end of stitches */

    xxxEncodeDesign(file, pattern);

    endOfStitches = ftell(file);

    fseek(file, 0xFC, SEEK_SET);

    binaryWriteUInt(file, endOfStitches);

    fseek(file, 0, SEEK_END);

    binaryWriteByte(file, 0x7F); /* is this really correct? */
    binaryWriteByte(file, 0x7F);
    binaryWriteByte(file, 0x03);
    binaryWriteByte(file, 0x14);
    binaryWriteByte(file, 0x00);
    binaryWriteByte(file, 0x00);
    colors = pattern->threadList;
    while(colors)
    {
        binaryWriteByte(file, 0x00);
        binaryWriteByte(file, colors->thread.color.r);
        binaryWriteByte(file, colors->thread.color.g);
        binaryWriteByte(file, colors->thread.color.b);
        curColor++;
        colors = colors->next;
    }
    for(i = 0; i < (22 - curColor); i++)
    {
        binaryWriteUInt(file, 0x01000000);
    }
    binaryWriteByte(file, 0x00);
    binaryWriteByte(file, 0x01);
    fclose(file);
    return 1;
}
예제 #5
0
/*! Writes the data from \a pattern to a file with the given \a fileName.
 *  Returns \c true if successful, otherwise returns \c false. */
int writeVp3(EmbPattern* pattern, const char* fileName)
{
    EmbFile *file = 0;
    EmbRect bounds;
    int remainingBytesPos, remainingBytesPos2;
    int colorSectionStitchBytes;
    int first = 1;
    int numberOfColors = 0;
    EmbColor color;
    EmbStitchList *mainPointer = 0, *pointer = 0;

    if(!pattern) { embLog_error("format-vp3.c writeVp3(), pattern argument is null\n"); return 0; }
    if(!fileName) { embLog_error("format-vp3.c writeVp3(), fileName argument is null\n"); return 0; }

    if(!embStitchList_count(pattern->stitchList))
    {
        embLog_error("format-vp3.c writeVp3(), pattern contains no stitches\n");
        return 0;
    }

    bounds = embPattern_calcBoundingBox(pattern);

    file = embFile_open(fileName, "wb");
    if(!file)
    {
        embLog_error("format-vp3.c writeVp3(), cannot open %s for writing\n", fileName);
        return 0;
    }

    embPattern_correctForMaxStitchLength(pattern, 3200.0, 3200.0); /* VP3 can encode signed 16bit deltas */

    embPattern_flipVertical(pattern);

    binaryWriteBytes(file, "%vsm%", 5);
    binaryWriteByte(file, 0);
    vp3WriteString(file, "Embroidermodder");
    binaryWriteByte(file, 0);
    binaryWriteByte(file, 2);
    binaryWriteByte(file, 0);

    remainingBytesPos = embFile_tell(file);
    binaryWriteInt(file, 0); /* placeholder */
    vp3WriteString(file, "");
    binaryWriteIntBE(file, bounds.right * 1000);
    binaryWriteIntBE(file, bounds.bottom * 1000);
    binaryWriteIntBE(file, bounds.left * 1000);
    binaryWriteIntBE(file, bounds.top * 1000);
    binaryWriteInt(file, 0); /* this would be some (unknown) function of thread length */
    binaryWriteByte(file, 0);

    numberOfColors = 0;

    mainPointer = pattern->stitchList;
    while(mainPointer)
    {
        int flag;
        EmbColor newColor;

        pointer = mainPointer;
        flag = pointer->stitch.flags;
        newColor = embThreadList_getAt(pattern->threadList, pointer->stitch.color).color;
        if(newColor.r != color.r || newColor.g != color.g || newColor.b != color.b)
        {
            numberOfColors++;
            color.r = newColor.r;
            color.g = newColor.g;
            color.b = newColor.b;
        }
        else if(flag & END || flag & STOP)
        {
            numberOfColors++;
        }

        while(pointer && (flag == pointer->stitch.flags))
        {
            pointer = pointer->next;
        }
        mainPointer = pointer;
    }

    binaryWriteByte(file, numberOfColors);
    binaryWriteByte(file, 12);
    binaryWriteByte(file, 0);
    binaryWriteByte(file, 1);
    binaryWriteByte(file, 0);
    binaryWriteByte(file, 3);
    binaryWriteByte(file, 0);

    remainingBytesPos2 = embFile_tell(file);
    binaryWriteInt(file, 0); /* placeholder */

    binaryWriteIntBE(file, 0); /* origin X */
    binaryWriteIntBE(file, 0); /* origin Y */
    binaryWriteByte(file, 0);
    binaryWriteByte(file, 0);
    binaryWriteByte(file, 0);

    binaryWriteIntBE(file, bounds.right * 1000);
    binaryWriteIntBE(file, bounds.bottom * 1000);
    binaryWriteIntBE(file, bounds.left * 1000);
    binaryWriteIntBE(file, bounds.top * 1000);

    binaryWriteIntBE(file, (bounds.right - bounds.left) * 1000);
    binaryWriteIntBE(file, (bounds.bottom - bounds.top) * 1000);

    vp3WriteString(file, "");
    binaryWriteShortBE(file, 25700);
    binaryWriteIntBE(file, 4096);
    binaryWriteIntBE(file, 0);
    binaryWriteIntBE(file, 0);
    binaryWriteIntBE(file, 4096);

    binaryWriteBytes(file, "xxPP\x01\0", 6);
    vp3WriteString(file, "");
    binaryWriteShortBE(file, numberOfColors);

    mainPointer = pattern->stitchList;
    while(mainPointer)
    {
        char colorName[8] = { 0 };
        double lastX, lastY;
        int colorSectionLengthPos;
        EmbStitch s;
        int lastColor;

        if(!first)
            binaryWriteByte(file, 0);
        binaryWriteByte(file, 0);
        binaryWriteByte(file, 5);
        binaryWriteByte(file, 0);

        colorSectionLengthPos = embFile_tell(file);
        binaryWriteInt(file, 0); /* placeholder */

        pointer = mainPointer;
        color = embThreadList_getAt(pattern->threadList, pointer->stitch.color).color;

        if(first && pointer->stitch.flags & JUMP && pointer->next->stitch.flags & JUMP)
            pointer = pointer->next;

        s = pointer->stitch;
        embLog_print("format-vp3.c DEBUG %d, %lf, %lf\n", s.flags, s.xx, s.yy);
        binaryWriteIntBE(file, s.xx * 1000);
        binaryWriteIntBE(file, -s.yy * 1000);
        pointer = pointer->next;

        first = 0;

        lastX = s.xx;
        lastY = s.yy;
        lastColor = s.color;

        binaryWriteByte(file, 1);
        binaryWriteByte(file, 0);

        embLog_print("format-vp3.c writeVp3(), switching to color (%d, %d, %d)\n", color.r, color.g, color.b);
        binaryWriteByte(file, color.r);
        binaryWriteByte(file, color.g);
        binaryWriteByte(file, color.b);

        binaryWriteByte(file, 0);
        binaryWriteByte(file, 0);
        binaryWriteByte(file, 0);
        binaryWriteByte(file, 5);
        binaryWriteByte(file, 40);

        vp3WriteString(file, "");

        sprintf(colorName, "#%02x%02x%02x", color.b, color.g, color.r);

        vp3WriteString(file, colorName);
        vp3WriteString(file, "");

        binaryWriteIntBE(file, 0);
        binaryWriteIntBE(file, 0);

        vp3WriteStringLen(file, "\0", 1);

        colorSectionStitchBytes = embFile_tell(file);
        binaryWriteInt(file, 0); /* placeholder */

        binaryWriteByte(file, 10);
        binaryWriteByte(file, 246);
        binaryWriteByte(file, 0);

        while(pointer)
        {
            int dx, dy;

            EmbStitch s = pointer->stitch;
            if(s.color != lastColor)
                break;
            if(s.flags & END || s.flags & STOP)
                break;

            dx = (s.xx - lastX) * 10;
            dy = (s.yy - lastY) * 10;
            lastX = lastX + dx / 10.0; /* output is in ints, ensure rounding errors do not sum up */
            lastY = lastY + dy / 10.0;

            if(dx < -127 || dx > 127 || dy < -127 || dy > 127)
            {
                binaryWriteByte(file, 128);
                binaryWriteByte(file, 1);
                binaryWriteShortBE(file, dx);
                binaryWriteShortBE(file, dy);
                binaryWriteByte(file, 128);
                binaryWriteByte(file, 2);
            }
            else
            {
                binaryWriteByte(file, dx);
                binaryWriteByte(file, dy);
            }

            pointer = pointer->next;
        }

        vp3PatchByteCount(file, colorSectionStitchBytes, -4);
        vp3PatchByteCount(file, colorSectionLengthPos, -3);

        mainPointer = pointer;
    }

    vp3PatchByteCount(file, remainingBytesPos2, -4);
    vp3PatchByteCount(file, remainingBytesPos, -4);

    embFile_close(file);

    embPattern_flipVertical(pattern);

    return 1;
}
예제 #6
0
/*! Writes the data from \a pattern to a file with the given \a fileName.
 *  Returns \c true if successful, otherwise returns \c false. */
int writeJef(EmbPattern* pattern, const char* fileName)
{
    int colorlistSize, minColors, designWidth, designHeight, i;
    EmbRect boundingRect;
    FILE* file = 0;
    EmbTime time;
    EmbThreadList* threadPointer = 0;
    EmbStitch c;
    EmbStitchList* pointer = 0;
    double prevX, prevY;

    if(!pattern) { embLog_error("format-jef.c writeJef(), pattern argument is null\n"); return 0; }
    if(!fileName) { embLog_error("format-jef.c writeJef(), fileName argument is null\n"); return 0; }

    if(!embStitchList_count(pattern->stitchList))
    {
        embLog_error("format-jef.c writeJef(), pattern contains no stitches\n");
        return 0;
    }

    /* Check for an END stitch and add one if it is not present */
    if(pattern->lastStitch->stitch.flags != END)
        embPattern_addStitchRel(pattern, 0, 0, END, 1);

    file = fopen(fileName, "wb");
    if(!file)
    {
        embLog_error("format-jef.c writeJef(), cannot open %s for writing\n", fileName);
        return 0;
    }

    embPattern_correctForMaxStitchLength(pattern, 127, 127);

    colorlistSize = embThreadList_count(pattern->threadList);
    minColors = max(colorlistSize, 6);
    binaryWriteInt(file, 0x74 + (minColors * 4));
    binaryWriteInt(file, 0x0A);

    embTime_initNow(&time);

    fprintf(file, "%04d%02d%02d%02d%02d%02d", (int)(time.year + 1900),
            (int)(time.month + 1), (int)(time.day), (int)(time.hour),
            (int)(time.minute), (int)(time.second));
    binaryWriteByte(file, 0x00);
    binaryWriteByte(file, 0x00);
    binaryWriteInt(file, embThreadList_count(pattern->threadList));
    binaryWriteInt(file, embStitchList_count(pattern->stitchList) + max(0, (6 - colorlistSize) * 2) + 1);

    boundingRect = embPattern_calcBoundingBox(pattern);

    designWidth = (int)(embRect_width(boundingRect) * 10.0);
    designHeight = (int)(embRect_width(boundingRect) * 10.0);

    binaryWriteInt(file, jefGetHoopSize(designWidth, designHeight));

    /* Distance from center of Hoop */
    binaryWriteInt(file, (int) (designWidth / 2));  /* left */
    binaryWriteInt(file, (int) (designHeight / 2)); /* top */
    binaryWriteInt(file, (int) (designWidth / 2));  /* right */
    binaryWriteInt(file, (int) (designHeight / 2)); /* bottom */

    /* Distance from default 110 x 110 Hoop */
    if(min(550 - designWidth / 2, 550 - designHeight / 2) >= 0)
    {
        binaryWriteInt(file, (int) max(-1, 550 - designWidth / 2));  /* left */
        binaryWriteInt(file, (int) max(-1, 550 - designHeight / 2)); /* top */
        binaryWriteInt(file, (int) max(-1, 550 - designWidth / 2));  /* right */
        binaryWriteInt(file, (int) max(-1, 550 - designHeight / 2)); /* bottom */
    }
    else
    {
        binaryWriteInt(file, -1);
        binaryWriteInt(file, -1);
        binaryWriteInt(file, -1);
        binaryWriteInt(file, -1);
    }

    /* Distance from default 50 x 50 Hoop */
    if(min(250 - designWidth / 2, 250 - designHeight / 2) >= 0)
    {
        binaryWriteInt(file, (int) max(-1, 250 - designWidth / 2));  /* left */
        binaryWriteInt(file, (int) max(-1, 250 - designHeight / 2)); /* top */
        binaryWriteInt(file, (int) max(-1, 250 - designWidth / 2));  /* right */
        binaryWriteInt(file, (int) max(-1, 250 - designHeight / 2)); /* bottom */
    }
    else
    {
        binaryWriteInt(file, -1);
        binaryWriteInt(file, -1);
        binaryWriteInt(file, -1);
        binaryWriteInt(file, -1);
    }

    /* Distance from default 140 x 200 Hoop */
    binaryWriteInt(file, (int) (700 - designWidth / 2));   /* left */
    binaryWriteInt(file, (int) (1000 - designHeight / 2)); /* top */
    binaryWriteInt(file, (int) (700 - designWidth / 2));   /* right */
    binaryWriteInt(file, (int) (1000 - designHeight / 2)); /* bottom */

    /* repeated Distance from default 140 x 200 Hoop */
    /* TODO: Actually should be distance to custom hoop */
    binaryWriteInt(file, (int) (630 - designWidth / 2));  /* left */
    binaryWriteInt(file, (int) (550 - designHeight / 2)); /* top */
    binaryWriteInt(file, (int) (630 - designWidth / 2));  /* right */
    binaryWriteInt(file, (int) (550 - designHeight / 2)); /* bottom */

    threadPointer = pattern->threadList;

    while(threadPointer)
    {
        binaryWriteInt(file, embThread_findNearestColorInArray(threadPointer->thread.color, (EmbThread*)jefThreads, 79));
        threadPointer = threadPointer->next;
    }
    for(i = 0; i < (minColors - colorlistSize); i++)
    {
        binaryWriteInt(file, 0x0D);
    }
    pointer = pattern->stitchList;

    prevX = pointer->stitch.xx;
    prevY = pointer->stitch.yy;
    jefEncode(file, (unsigned char) prevX, (unsigned char) prevY, pointer->stitch.flags);
    pointer = pointer->next;
    while(pointer)
    {
        c = pointer->stitch;
        jefEncode(file, (unsigned char) (c.xx - prevX), (unsigned char) (c.yy - prevY), c.flags);
        prevX = c.xx;
        prevY = c.yy;
        pointer = pointer->next;
    }
    fclose(file);
    return 1;
}
예제 #7
0
/*! Writes the data from \a pattern to a file with the given \a fileName.
 *  Returns \c true if successful, otherwise returns \c false. */
int writeDst(EmbPattern* pattern, const char* fileName)
{
    EmbRect boundingRect;
    FILE* file = 0;
    int xx, yy, dx, dy, flags;
    int i;
    int co = 1, st = 0;
    int ax, ay, mx, my;
    char* pd = 0;
    EmbStitchList* pointer = 0;

    if(!pattern) { embLog_error("format-dst.c writeDst(), pattern argument is null\n"); return 0; }
    if(!fileName) { embLog_error("format-dst.c writeDst(), fileName argument is null\n"); return 0; }

    file = fopen(fileName, "wb");
    if(!file)
    {
        embLog_error("format-dst.c writeDst(), cannot open %s for writing\n", fileName);
        return 0;
    }
    embPattern_correctForMaxStitchLength(pattern, 12.1, 12.1);

    xx = yy = 0;
    co = 1;
    co = embThreadList_count(pattern->threadList);
    st = 0;
    st = embStitchList_count(pattern->stitchList);
    flags = NORMAL;
    boundingRect = embPattern_calcBoundingBox(pattern);
    /* TODO: review the code below
    if (pattern->get_variable("design_name") != NULL)
    {
    char *la = stralloccopy(pattern->get_variable("design_name"));
    if (strlen(la)>16) la[16]='\0';

    fprintf(file,"LA:%-16s\x0d",la);
    free (la);
    }
    else
    {
    */
    fprintf(file, "LA:%-16s\x0d", "Untitled");
    /*} */
    fprintf(file, "ST:%7d\x0d", st);
    fprintf(file, "CO:%3d\x0d", co - 1); /* number of color changes, not number of colors! */
    fprintf(file, "+X:%5d\x0d", (int)(boundingRect.right * 10.0));
    fprintf(file, "-X:%5d\x0d", (int)(fabs(boundingRect.left) * 10.0));
    fprintf(file, "+Y:%5d\x0d", (int)(boundingRect.bottom * 10.0));
    fprintf(file, "-Y:%5d\x0d", (int)(fabs(boundingRect.top) * 10.0));


    ax = ay = mx = my = 0;
    /* TODO: review the code below */
    /*ax=pattern->get_variable_int("ax"); */ /* will return 0 if not defined */
    /*ay=pattern->get_variable_int("ay"); */
    /*mx=pattern->get_variable_int("mx"); */
    /*my=pattern->get_variable_int("my"); */

    /*pd=pattern->get_variable("pd");*/ /* will return null pointer if not defined */
    pd = 0;
    if(pd == 0 || strlen(pd) != 6)
    {
        /* pd is not valid, so fill in a default consisting of "******" */
        pd = "******";
    };
    fprintf(file, "AX:+%5d\x0d", ax);
    fprintf(file, "AY:+%5d\x0d", ay);
    fprintf(file, "MX:+%5d\x0d", mx);
    fprintf(file, "MY:+%5d\x0d", my);
    fprintf(file, "PD:%6s\x0d", pd);
    binaryWriteByte(file, 0x1a); /* 0x1a is the code for end of section. */

    /* pad out header to proper length */
    for(i = 125; i < 512; i++)
    {
        fprintf(file, " ");
    }

    /* write stitches */
    xx = yy = 0;
    pointer = pattern->stitchList;
    while(pointer)
    {
        /* convert from mm to 0.1mm for file format */
        dx = roundDouble(pointer->stitch.xx * 10.0) - xx;
        dy = roundDouble(pointer->stitch.yy * 10.0) - yy;
        xx = roundDouble(pointer->stitch.xx * 10.0);
        yy = roundDouble(pointer->stitch.yy * 10.0);
        flags = pointer->stitch.flags;
        encode_record(file, dx, dy, flags);
        pointer = pointer->next;
    }
    binaryWriteByte(file, 0xA1); /* finish file with a terminator character */
    binaryWriteShort(file, 0);
    fclose(file);
    return 1;
}