当前位置: 首页>>代码示例>>C++>>正文


C++ embPattern_addStitchRel函数代码示例

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


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


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