• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ embPattern_addStitchRel函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中embPattern_addStitchRel函数的典型用法代码示例。如果您正苦于以下问题:C++ embPattern_addStitchRel函数的具体用法?C++ embPattern_addStitchRel怎么用?C++ embPattern_addStitchRel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了embPattern_addStitchRel函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: readT09

int readT09(EmbPattern* pattern, const char* fileName)
{
    unsigned char b[3];
    FILE* file = 0;

    file = fopen(fileName, "rb");
    if(!file)
    {
        return 0;
    }
    fseek(file, 0x0C, SEEK_SET);

    while(fread(b, 1, 3, file) == 3)
    {
        int stitchType = NORMAL;
        int b1 = b[0];
        int b2 = b[1];
        unsigned char commandByte = b[2];
        if(commandByte == 0x00)
        {
            embPattern_addStitchRel(pattern, 0, 0, END, 1);
            break;
        }
        if (commandByte & 0x10) stitchType = STOP;
        if (commandByte & 0x20) b1 = -b1;
        if (commandByte & 0x40) b2 = -b2;

        embPattern_addStitchRel(pattern, b2 / 10.0, b1 / 10.0, stitchType, 1);
    }
    fclose(file);
    return 1;
}
开发者ID:Ravenleigh,项目名称:Embroidermodder,代码行数:32,代码来源:format-t09.c


示例2: read100

/*! Reads a file with the given \a fileName and loads the data into \a pattern.
 *  Returns \c true if successful, otherwise returns \c false. */
int read100(EmbPattern* pattern, const char* fileName)
{
    FILE* file = 0;
    int x,y;
    int stitchType;
    unsigned char b[4];

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

    file = fopen(fileName,"rb");
    if(!file)
    {
        embLog_error("format-100.c read100(), cannot open %s for reading\n", fileName);
        return 0;
    }
    embPattern_loadExternalColorFile(pattern, fileName);
    while(fread(b, 1, 4, file) == 4)
    {
        stitchType = NORMAL;
        x = (b[2] > 0x80) ? -(b[2] - 0x80) : b[2];
        y = (b[3] > 0x80) ? -(b[3] - 0x80) : b[3];
        /*if(!(b[0] & 0xFC)) stitchType = JUMP; TODO: review & fix */
        if(!(b[0] & 0x01)) stitchType = STOP;
        if(b[0] == 0x1F) stitchType = END;
        embPattern_addStitchRel(pattern, x / 10.0, y / 10.0, stitchType, 1);
    }
    fclose(file);

    /* 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);

    return 1;
}
开发者ID:FMMT666,项目名称:Embroidermodder,代码行数:37,代码来源:format-100.c


示例3: movePolylinesToStitchList

/* TODO: It doesn't appear that this function actually clears the polylineObjList so it is more of a copy than a move. */
void movePolylinesToStitchList(EmbPattern* p)
{
    if(p)
    {
        EmbPolylineObjectList* polyList = p->polylineObjList;
        EmbStitchList* currentList = 0;
        int firstObject = 1;
        /*int currentColor = polyList->polylineObj->color TODO: polyline color */
        while(polyList)
        {
            EmbPolylineObject* currentPoly = polyList->polylineObj;
            EmbPointList* currentPointList = currentPoly->pointList;
            EmbThread thread;
            thread.catalogNumber = 0;
            thread.color = currentPoly->color;
            thread.description = 0;
            embPattern_addThread(p, thread);
            if(!firstObject)
            {
                embPattern_addStitchRel(p, currentPointList->point.xx, currentPointList->point.yy, TRIM, 1);
                embPattern_addStitchRel(p, 0.0, 0.0, STOP, 1);
                firstObject = 0;
            }
            while(currentPointList)
            {
                embPattern_addStitchAbs(p, currentPointList->point.xx, currentPointList->point.yy, NORMAL, 1);
                currentPointList = currentPointList->next;
            }

            polyList = polyList->next;
        }
        embPattern_addStitchRel(p, 0.0, 0.0, END, 1);
    }
}
开发者ID:SushiTee,项目名称:Embroidermodder,代码行数:35,代码来源:emb-pattern.c


示例4: readMit

/*! Reads a file with the given \a fileName and loads the data into \a pattern.
 *  Returns \c true if successful, otherwise returns \c false. */
int readMit(EmbPattern* pattern, const char* fileName)
{
    unsigned char data[2];
    EmbFile* file = 0;

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

    file = embFile_open(fileName, "rb");
    if(!file)
    {
        embLog_error("format-mit.c readMit(), cannot open %s for reading\n", fileName);
        return 0;
    }

    /* embPattern_loadExternalColorFile(pattern, fileName); TODO: review this and uncomment or remove it */

    while(binaryReadBytes(file, data, 2) == 2)
    {
        embPattern_addStitchRel(pattern, mitDecodeStitch(data[0]) / 10.0, mitDecodeStitch(data[1]) / 10.0, NORMAL, 1);
    }

    embFile_close(file);

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

    return 1;
}
开发者ID:Embroidermodder,项目名称:Embroidermodder,代码行数:32,代码来源:format-mit.c


示例5: readZsk

int readZsk(EmbPattern* pattern, const char* fileName)
{
    int b[3];
    FILE* file = fopen(fileName, "rb");

    if(file == 0)
        return 0;

    fseek(file, 512, SEEK_SET);

    while(fread(b, 1, 3, file) == 3)
    {
        if((b[2] & 25) == 0)
        {
            if(b[2] & 0x40)
                b[1] = -b[1];
            if(b[2] & 0x20)
                b[0] = -b[0];
            embPattern_addStitchRel(pattern, b[1] / 10.0, b[0] / 10.0, NORMAL, 1);
        }
        else
        {
            embPattern_addStitchRel(pattern, b[1] / 10.0, b[0] / 10.0, STOP, 1);
        }
    }
    embPattern_addStitchRel(pattern, 0, 0, END, 1);
    fclose(file);
    return 1;
}
开发者ID:claudeocquidant,项目名称:Embroidermodder,代码行数:29,代码来源:format-zsk.c


示例6: embPattern_copyPolylinesToStitchList

void embPattern_copyPolylinesToStitchList(EmbPattern* p)
{
    EmbPolylineObjectList* polyList = 0;
    EmbStitchList* currentList = 0;
    int firstObject = 1;
    /*int currentColor = polyList->polylineObj->color TODO: polyline color */

    if(!p) { embLog_error("emb-pattern.c embPattern_copyPolylinesToStitchList(), p argument is null\n"); return; }
    polyList = p->polylineObjList;
    while(polyList)
    {
        EmbPolylineObject* currentPoly = polyList->polylineObj;
        EmbPointList* currentPointList = currentPoly->pointList;
        EmbThread thread;
        thread.catalogNumber = 0;
        thread.color = currentPoly->color;
        thread.description = 0;
        embPattern_addThread(p, thread);
        if(!firstObject)
        {
            embPattern_addStitchRel(p, currentPointList->point.xx, currentPointList->point.yy, TRIM, 1);
            embPattern_addStitchRel(p, 0.0, 0.0, STOP, 1);
            firstObject = 0;
        }
        while(currentPointList)
        {
            embPattern_addStitchAbs(p, currentPointList->point.xx, currentPointList->point.yy, NORMAL, 1);
            currentPointList = currentPointList->next;
        }

        polyList = polyList->next;
    }
    embPattern_addStitchRel(p, 0.0, 0.0, END, 1);
}
开发者ID:seeligal,项目名称:Embroidermodder,代码行数:34,代码来源:emb-pattern.c


示例7: readNew

/*! Reads a file with the given \a fileName and loads the data into \a pattern.
 *  Returns \c true if successful, otherwise returns \c false. */
int readNew(EmbPattern* pattern, const char* fileName)
{
    unsigned int stitchCount;
    unsigned char data[3];
    FILE* file = 0;

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

    file = fopen(fileName, "rb");
    if(!file)
    {
        embLog_error("format-new.c readNew(), cannot open %s for reading\n", fileName);
        return 0;
    }

    embPattern_loadExternalColorFile(pattern, fileName);
    stitchCount = binaryReadUInt16(file);
    while(binaryReadBytes(file, data, 3) == 3)
    {
        int x = decodeNewStitch(data[0]);
        int y = decodeNewStitch(data[1]);
        int flag = NORMAL;
        char val = data[2];
        if(data[2] & 0x40)
        {
            x = -x;
        }
        if(data[2] & 0x20)
        {
            y = -y;
        }
        if(data[2] & 0x10)
        {
            flag = TRIM;
        }
        if(data[2] & 0x01)
        {
            flag = JUMP;
        }
        if((val & 0x1E) == 0x02)
        {
            flag = STOP;
        }
        /* Unknown values, possibly TRIM
        155 = 1001 1011 = 0x9B
        145 = 1001 0001 = 0x91
        */
        /*val = (data[2] & 0x1C);
        if(val != 0 && data[2] != 0x9B && data[2] != 0x91)
        {
            int z = 1;
        }*/
        embPattern_addStitchRel(pattern, x / 10.0, y / 10.0, flag, 1);
    }
    embPattern_addStitchRel(pattern, 0.0, 0.0, END, 1);
    return 1;
}
开发者ID:craftoid,项目名称:Embroidermodder,代码行数:60,代码来源:format-new.c


示例8: readDsb

int readDsb(EmbPattern* pattern, const char* fileName)
{
    FILE* file = 0;

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

    file = fopen(fileName,"rb");
    if(file==0)
    {
        embLog_error("format-dsb.c readDsb(), cannot open %s for reading\n", fileName);
        return 0;
    }

    embPattern_loadExternalColorFile(pattern, fileName);
    /*TODO: READ 512 BYTE HEADER INTO header[] */
    /*
    for(i=0;i<512;i++)
    {
        header[i]=fgetc(file);
    }
    */
    fseek(file, 0x200, SEEK_SET);
    while(1)
    {
        int stitchType = NORMAL;
        int x, y;
        unsigned char ctrl =(unsigned char)fgetc(file);
        if(feof(file)) break;
        y = fgetc(file);
        if(feof(file)) break;
        x = fgetc(file);
        if(feof(file)) break;
        if(ctrl & 0x20)
            x = -x;
        if(ctrl & 0x40)
            y = -y;
        if(ctrl & 0x01)
            stitchType = TRIM;
        /* ctrl & 0x02 - Speed change? */
        /* ctrl & 0x04 - Clutch? */
        if((ctrl & 0x05) == 0x05)
        {
            stitchType = STOP;
        }
        if(ctrl == 0xF8 || ctrl == 0x91 || ctrl == 0x87)
        {
            embPattern_addStitchRel(pattern, 0, 0, END, 1);
            break;
        }
        embPattern_addStitchRel(pattern, x / 10.0, y / 10.0, stitchType, 1);
    }
    fclose(file);
    return 1;
}
开发者ID:seeligal,项目名称:Embroidermodder,代码行数:55,代码来源:format-dsb.c


示例9: read10o

/*! Reads a file with the given \a fileName and loads the data into \a pattern.
 *  Returns \c true if successful, otherwise returns \c false. */
int read10o(EmbPattern* pattern, const char* fileName)
{
    FILE* file = 0;

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

    file = fopen(fileName,"rb");
    if(!file)
    {
        embLog_error("format-10o.c read10o(), cannot open %s for reading\n", fileName);
        return 0;
    }

    embPattern_loadExternalColorFile(pattern, fileName);

    while(1)
    {
        int x, y;
        int stitchType = NORMAL;
        unsigned char ctrl = (unsigned char)fgetc(file);
        if(feof(file))
            break;
        y = fgetc(file);
        if(feof(file))
            break;
        x = fgetc(file);
        if(feof(file))
            break;
        if(ctrl & 0x20)
            x = -x;
        if(ctrl & 0x40)
            y = -y;
        if(ctrl & 0x01)
            stitchType = TRIM;
        if((ctrl & 0x5) == 5)
        {
            stitchType = STOP;
        }
        if(ctrl == 0xF8 || ctrl == 0x91 || ctrl == 0x87)
        {
            embPattern_addStitchRel(pattern, 0, 0, END, 1);
            break;
        }
        embPattern_addStitchRel(pattern, x / 10.0, y / 10.0, stitchType, 1);
    }
    fclose(file);

    /* 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);

    return 1;
}
开发者ID:FMMT666,项目名称:Embroidermodder,代码行数:56,代码来源:format-10o.c


示例10: readSst

/*! Reads a file with the given \a fileName and loads the data into \a pattern.
 *  Returns \c true if successful, otherwise returns \c false. */
int readSst(EmbPattern* pattern, const char* fileName)
{
    int fileLength;
    EmbFile* file = 0;

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

    file = embFile_open(fileName, "rb");
    if(!file)
    {
        embLog_error("format-sst.c readSst(), cannot open %s for reading\n", fileName);
        return 0;
    }

    embPattern_loadExternalColorFile(pattern, fileName);
    embFile_seek(file, 0, SEEK_END);
    fileLength = embFile_tell(file);
    embFile_seek(file, 0xA0, SEEK_SET); /* skip the all zero header */
    while(embFile_tell(file) < fileLength)
    {
        int stitchType = NORMAL;

        int b1 = (int) binaryReadByte(file);
        int b2 = (int) binaryReadByte(file);
        unsigned char commandByte = binaryReadByte(file);

        if(commandByte == 0x04)
        {
            embPattern_addStitchRel(pattern, 0, 0, END, 1);
            break;
        }

        if((commandByte & 0x01) == 0x01)
            stitchType = STOP;
        if((commandByte & 0x02) == 0x02)
            stitchType = JUMP;
        if((commandByte & 0x10) != 0x10)
            b2 = -b2;
        if((commandByte & 0x40) == 0x40)
            b1 = -b1;
        embPattern_addStitchRel(pattern, b1 / 10.0, b2 / 10.0, stitchType, 1);
    }

    embFile_close(file);

    /* 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);

    return 1; /*TODO: finish readSst */
}
开发者ID:Allen76,项目名称:Embroidermodder,代码行数:54,代码来源:format-sst.c


示例11: readDat

int readDat(EmbPattern* pattern, const char* fileName)
{
    int fileLength, stitchesRemaining;
    FILE* file = 0;

    file = fopen(fileName, "rb");
    if(!file)
    {
        return 0;
    }
    embPattern_loadExternalColorFile(pattern, fileName);
    fseek(file, 0x00, SEEK_END);
    fileLength = ftell(file);
    fseek(file, 0x02, SEEK_SET);
    stitchesRemaining = binaryReadUInt16(file);
    fseek(file, 0x100, SEEK_SET);

    while(ftell(file)< fileLength)
    {
        int b1 = (int)binaryReadUInt8(file);
        int b2 = (int)binaryReadUInt8(file);
        unsigned char b0 = binaryReadByte(file);

        int stitchType = NORMAL;
        stitchesRemaining--;

        if((b0 & 0x02) == 0) stitchType = TRIM;

        if(b0 == 0x87)
        {
            stitchType = STOP;
        }
        if(b0 == 0xF8)
        {
            break;
        }
        if(b1 >= 0x80)
        {
            b1 = -(b1 & 0x7F);
        }
        if(b2 >= 0x80)
        {
            b2 = -(b2 & 0x7F);
        }
        embPattern_addStitchRel(pattern, b1 / 10.0, b2 / 10.0, stitchType, 1);
    }
    fclose(file);
    embPattern_addStitchRel(pattern, 0, 0, END, 1);
    return 1;
}
开发者ID:Ravenleigh,项目名称:Embroidermodder,代码行数:50,代码来源:format-dat.c


示例12: readDsb

int readDsb(EmbPattern* pattern, const char* fileName)
{
    FILE* file= fopen(fileName,"rb");
    if(file==0)
    {
        /*TODO: set messages here "Error opening DSB file for read:" */
        return 0;
    }
    embPattern_loadExternalColorFile(pattern, fileName);
    /*TODO: READ 512 BYTE HEADER INTO header[] */
    /*
    for(i=0;i<512;i++)
    {
        header[i]=fgetc(file);
    }
    */
    fseek(file, 0x200, SEEK_SET);
    while(1)
    {
        int stitchType = NORMAL;
        int x, y;
        unsigned char ctrl =(unsigned char)fgetc(file);
        if(feof(file)) break;
        y = fgetc(file);
        if(feof(file)) break;
        x = fgetc(file);
        if(feof(file)) break;
        if(ctrl & 0x20)
            x = -x;
        if(ctrl & 0x40)
            y = -y;
        if(ctrl & 0x01)
            stitchType = TRIM;
		/* ctrl & 0x02 - Speed change? */
		/* ctrl & 0x04 - Clutch? */
        if((ctrl & 0x05) == 0x05)
        {
            stitchType = STOP;
        }
        if(ctrl == 0xF8 || ctrl == 0x91 || ctrl == 0x87)
        {
            embPattern_addStitchRel(pattern, 0, 0, END, 1);
            break;
        }
        embPattern_addStitchRel(pattern, x / 10.0, y / 10.0, stitchType, 1);
    }
    fclose(file);
    return 1;
}
开发者ID:Ravenleigh,项目名称:Embroidermodder,代码行数:49,代码来源:format-dsb.c


示例13: writePec

/*! 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;
}
开发者ID:strixaluco,项目名称:Embroidermodder,代码行数:35,代码来源:format-pec.c


示例14: read100

int read100(EmbPattern* pattern, const char* fileName)
{
    FILE* file;
    int x,y;
    int stitchType;
    unsigned char b[4];

    file= fopen(fileName,"rb");
    if(file==0)
    {
        return 0;
    }
    embPattern_loadExternalColorFile(pattern, fileName);
    while(fread(b, 1, 4, file) == 4)
    {
        stitchType = NORMAL;
        x = (b[2] > 0x80) ? -(b[2] - 0x80) : b[2];
        y = (b[3] > 0x80) ? -(b[3] - 0x80) : b[3];
        /*if(!(b[0] & 0xFC)) stitchType = JUMP; TODO: review & fix */
        if(!(b[0] & 0x01)) stitchType = STOP;
        if(b[0] == 0x1F) stitchType = END;
        embPattern_addStitchRel(pattern, x / 10.0, y / 10.0, stitchType, 1);
    }
    fclose(file);
    return 1;
}
开发者ID:SushiTee,项目名称:Embroidermodder,代码行数:26,代码来源:format-100.c


示例15: readOfm

/*! Reads a file with the given \a fileName and loads the data into \a pattern.
 *  Returns \c true if successful, otherwise returns \c false. */
int readOfm(EmbPattern* pattern, const char* fileName)
{
    int unknownCount = 0;
    int key = 0, classNameLength;
    char* s = 0;
    FILE* fileCompound = 0;
    FILE* file = 0;
    bcf_file* bcfFile = 0;

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

    fileCompound = fopen(fileName, "rb");
    if(!fileCompound)
    {
        embLog_error("format-ofm.c readOfm(), cannot open %s for reading\n", fileName);
        return 0;
    }

    bcfFile = (bcf_file*)malloc(sizeof(bcf_file));
    if(!bcfFile) { embLog_error("format-ofm.c readOfm(), unable to allocate memory for bcfFile\n"); return 0; }
    bcfFile_read(fileCompound, bcfFile);
    file = GetFile(bcfFile, fileCompound, "EdsIV Object");
    bcf_file_free(bcfFile);
    bcfFile = 0;
    fseek(file, 0x1C6, SEEK_SET);
    ofmReadThreads(file, pattern);
    fseek(file, 0x110, SEEK_CUR);
    binaryReadInt32(file);
    classNameLength = binaryReadInt16(file);
    s = (char*)malloc(sizeof(char) * classNameLength);
    if(!s) { embLog_error("format-ofm.c readOfm(), unable to allocate memory for s\n"); return 0; }
    binaryReadBytes(file, (unsigned char*)s, classNameLength);
    unknownCount = binaryReadInt16(file); /* unknown count */

    binaryReadInt16(file);
    key = ofmReadClass(file);
    while(1)
    {
        if(key == 0xFEFF)
        {
            break;
        }
        if(key == 0x809C)
        {
            ofmReadExpanded(file, pattern);
        }
        else
        {
            ofmReadColorChange(file, pattern);
        }
        key = binaryReadUInt16(file);
        if(key == 0xFFFF)
        {
            ofmReadClass(file);
        }
    }
    embPattern_addStitchRel(pattern, 0.0, 0.0, END, 1);
    return 1;
}
开发者ID:craftoid,项目名称:Embroidermodder,代码行数:62,代码来源:format-ofm.c


示例16: readMax

int readMax(EmbPattern* pattern, const char* fileName)
{
    int i;
    unsigned char b[8];
    double dx = 0, dy = 0;
    int flags = 0;
    int stitchCount;
    FILE* file;

    file = fopen(fileName, "rb");
    if(file == 0)
    {
        return 0;
    }
    fseek(file, 0xD5, SEEK_SET);
    stitchCount = binaryReadUInt32(file);

    /* READ STITCH RECORDS */
    for(i = 0; i < stitchCount; i++)
    {
        flags = NORMAL;
        if(fread(b, 1, 8, file) != 8)
            break;

        dx = maxDecode(b[0], b[1], b[2]);
        dy = maxDecode(b[4], b[5], b[6]);
        embPattern_addStitchAbs(pattern, dx / 10.0, dy / 10.0, flags, 1);
    }
    embPattern_addStitchRel(pattern, 0, 0, END, 1);
	embPattern_flipVertical(pattern);
    fclose(file);
    return 1;
}
开发者ID:claudeocquidant,项目名称:Embroidermodder,代码行数:33,代码来源:format-max.c


示例17: readFxy

/*! Reads a file with the given \a fileName and loads the data into \a pattern.
 *  Returns \c true if successful, otherwise returns \c false. */
int readFxy(EmbPattern* pattern, const char* fileName)
{
    EmbFile* file = 0;

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

    file = embFile_open(fileName, "rb");
    if(!file)
    {
        embLog_error("format-fxy.c readFxy(), cannot open %s for reading\n", fileName);
        return 0;
    }

    embPattern_loadExternalColorFile(pattern, fileName);
    embFile_seek(file, 0x100, SEEK_SET); /* TODO: review for combining code. This line appears to be the only difference from the GT format. */

    while(!embFile_eof(file))
    {
        int stitchType = NORMAL;
        int b1 = (int)binaryReadByte(file);
        int b2 = (int)binaryReadByte(file);
        unsigned char commandByte = binaryReadByte(file);

        if(commandByte == 0x91)
        {
            embPattern_addStitchRel(pattern, 0, 0, END, 1);
            break;
        }
        if((commandByte & 0x01) == 0x01)
            stitchType = TRIM;
        if((commandByte & 0x02) == 0x02)
            stitchType = STOP;
        if((commandByte & 0x20) == 0x20)
            b1 = -b1;
        if((commandByte & 0x40) == 0x40)
            b2 = -b2;
        embPattern_addStitchRel(pattern, b2 / 10.0, b1 / 10.0, stitchType, 1);
    }
    embFile_close(file);

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

    return 1;
}
开发者ID:Embroidermodder,项目名称:Embroidermodder,代码行数:49,代码来源:format-fxy.c


示例18: readPec

/*! Reads a file with the given \a fileName and loads the data into \a pattern.
 *  Returns \c true if successful, otherwise returns \c false. */
int readPec(EmbPattern* pattern, const char* fileName)
{
    unsigned int graphicsOffset;
    unsigned char colorChanges;
    int i;
    EmbFile* file = 0;

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

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

    embFile_seek(file, 0x38, SEEK_SET);
    colorChanges = (unsigned char)binaryReadByte(file);
    for(i = 0; i <= colorChanges; i++)
    {
        embPattern_addThread(pattern, pecThreads[binaryReadByte(file) % 65]);
    }

    /* Get Graphics offset */
    embFile_seek(file, 0x20A, SEEK_SET);

    graphicsOffset = (unsigned int)(binaryReadUInt8(file));
    graphicsOffset |= (binaryReadUInt8(file) << 8);
    graphicsOffset |= (binaryReadUInt8(file) << 16);

    (void)binaryReadByte(file); /* 0x31 */
    (void)binaryReadByte(file); /* 0xFF */
    (void)binaryReadByte(file); /* 0xF0 */
    /* Get X and Y size in .1 mm */
    /* 0x210 */
    binaryReadInt16(file); /* x size */
    binaryReadInt16(file); /* y size */

    binaryReadInt16(file); /* 0x01E0 */
    binaryReadInt16(file); /* 0x01B0 */
    binaryReadInt16(file); /* distance left from start */
    binaryReadInt16(file); /* distance up from start */

    /* Begin Stitch Data */
    /* 0x21C */
    /*unsigned int end = graphicsOffset + 0x208; */
    readPecStitches(pattern, file);

    embFile_close(file);

    /* 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);

    embPattern_flipVertical(pattern);

    return 1;
}
开发者ID:strixaluco,项目名称:Embroidermodder,代码行数:61,代码来源:format-pec.c


示例19: ofmReadColorChange

static void ofmReadColorChange(EmbFile* file, EmbPattern* pattern)
{
    if(!file) { embLog_error("format-ofm.c ofmReadColorChange(), file argument is null\n"); return; }
    if(!pattern) { embLog_error("format-ofm.c ofmReadColorChange(), pattern argument is null\n"); return; }

    ofmReadBlockHeader(file);
    embPattern_addStitchRel(pattern, 0.0, 0.0, STOP, 1);
}
开发者ID:abrock,项目名称:Embroidermodder,代码行数:8,代码来源:format-ofm.c


示例20: writeExp

/*! Writes the data from \a pattern to a file with the given \a fileName.
 *  Returns \c true if successful, otherwise returns \c false. */
int writeExp(EmbPattern* pattern, const char* fileName)
{
#ifdef ARDUINO /* ARDUINO TODO: This is temporary. Remove when complete. */
return 0; /* ARDUINO TODO: This is temporary. Remove when complete. */
#else /* ARDUINO TODO: This is temporary. Remove when complete. */

    EmbFile* file = 0;
    EmbStitchList* stitches = 0;
    double dx = 0.0, dy = 0.0;
    double xx = 0.0, yy = 0.0;
    int flags = 0;
    unsigned char b[4];

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

    if(!embStitchList_count(pattern->stitchList))
    {
        embLog_error("format-exp.c writeExp(), 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-exp.c writeExp(), cannot open %s for writing\n", fileName);
        return 0;
    }

    /* write stitches */
    stitches = pattern->stitchList;
    while(stitches)
    {
        dx = stitches->stitch.xx * 10.0 - xx;
        dy = stitches->stitch.yy * 10.0 - yy;
        xx = stitches->stitch.xx * 10.0;
        yy = stitches->stitch.yy * 10.0;
        flags = stitches->stitch.flags;
        expEncode(b, (char)roundDouble(dx), (char)roundDouble(dy), flags);
        if((b[0] == 128) && ((b[1] == 1) || (b[1] == 2) || (b[1] == 4)))
        {
            embFile_printf(file, "%c%c%c%c", b[0], b[1], b[2], b[3]);
        }
        else
        {
            embFile_printf(file, "%c%c", b[0], b[1]);
        }
        stitches = stitches->next;
    }
    embFile_printf(file, "\x1a");
    embFile_close(file);
    return 1;
#endif /* ARDUINO TODO: This is temporary. Remove when complete. */
}
开发者ID:Allen76,项目名称:Embroidermodder,代码行数:60,代码来源:format-exp.c



注:本文中的embPattern_addStitchRel函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ embargoEffect函数代码示例发布时间:2022-05-30
下一篇:
C++ embInit函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap