⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 avc_binwr.c

📁 支持各种栅格图像和矢量图像读取的库
💻 C
📖 第 1 页 / 共 5 页
字号:
    AVCRawBinWriteInt32(psFile, psTxt->nUserId );    AVCRawBinWriteInt32(psFile, psTxt->nLevel );    AVCRawBinWriteFloat(psFile, psTxt->f_1e2 );    AVCRawBinWriteInt32(psFile, psTxt->nSymbol );    AVCRawBinWriteInt32(psFile, psTxt->numVerticesLine );    AVCRawBinWriteInt32(psFile, psTxt->n28 );    AVCRawBinWriteInt32(psFile, psTxt->numChars );    AVCRawBinWriteInt32(psFile, psTxt->numVerticesArrow );    for(i=0; i<20; i++)    {        AVCRawBinWriteInt16(psFile, psTxt->anJust1[i] );    }    for(i=0; i<20; i++)    {        AVCRawBinWriteInt16(psFile, psTxt->anJust2[i] );    }    if (nPrecision == AVC_SINGLE_PREC)    {        AVCRawBinWriteFloat(psFile, (float)psTxt->dHeight);        AVCRawBinWriteFloat(psFile, (float)psTxt->dV2);        AVCRawBinWriteFloat(psFile, (float)psTxt->dV3);    }    else    {        AVCRawBinWriteDouble(psFile, psTxt->dHeight);        AVCRawBinWriteDouble(psFile, psTxt->dV2);        AVCRawBinWriteDouble(psFile, psTxt->dV3);    }    if (nStrLen > 0)        AVCRawBinWritePaddedString(psFile, nStrLen, psTxt->pszText);    if (nPrecision == AVC_SINGLE_PREC)    {        for(i=0; i<numVertices; i++)        {            AVCRawBinWriteFloat(psFile, (float)psTxt->pasVertices[i].x);            AVCRawBinWriteFloat(psFile, (float)psTxt->pasVertices[i].y);        }    }    else    {        for(i=0; i<numVertices; i++)        {            AVCRawBinWriteDouble(psFile, psTxt->pasVertices[i].x);            AVCRawBinWriteDouble(psFile, psTxt->pasVertices[i].y);        }    }    AVCRawBinWriteZeros(psFile, 8);    /*-----------------------------------------------------------------     * Write index entry (cnx.adf)     *----------------------------------------------------------------*/    if (psIndexFile)    {        _AVCBinWriteIndexEntry(psIndexFile, nCurPos, nRecSize);    }    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                          _AVCBinWritePCCoverageTxt() * * (This function is for internal library use... external calls should * go to AVCBinWriteTxt() instead) * * Write a TXT (Annotation) structure to a AVCCoverPC file. * * The contents of the psTxt structure is assumed to be valid... this * function performs no validation on the consistency of what it is  * given as input. * * This function assumes that PC Coverages are always single precision. * * Returns 0 on success or -1 on error. **********************************************************************/int _AVCBinWritePCCoverageTxt(AVCRawBinFile *psFile, AVCTxt *psTxt,                               int nPrecision, AVCRawBinFile *psIndexFile){    int i, nRecSize, nCurPos, nStrLen, numVertices;    CPLAssert(nPrecision == AVC_SINGLE_PREC);    nCurPos = psFile->nCurPos/2;  /* Value in 2 byte words */    AVCRawBinWriteInt32(psFile, psTxt->nTxtId);    if (CPLGetLastErrorNo() != 0)        return -1;    /*-----------------------------------------------------------------     * Record size is expressed in 2 byte words, and does not count the     * first 8 bytes of the TXT entry.     *----------------------------------------------------------------*/    /* String uses a multiple of 4 bytes of storage,     * And if text is already a multiple of 4 bytes then we include 4 extra      * spaces anyways (was probably a bug in the software!).     */    if (psTxt->pszText)        nStrLen = ((strlen(psTxt->pszText) + 4)/4)*4;    else        nStrLen = 4;    nRecSize = (92 - 8 + nStrLen) / 2;    AVCRawBinWriteInt32(psFile, nRecSize);    AVCRawBinWriteInt32(psFile, psTxt->nLevel );    /*-----------------------------------------------------------------     * Number of vertices to write:     * Note that because of the way V7 binary TXT files work, the rest of the     * lib expects to receive duplicate coords for the first vertex, so     * we will also receive an additional vertex for that but we won't write     * it.  We also ignore the arrow vertices if there is any.     *----------------------------------------------------------------*/    numVertices = ABS(psTxt->numVerticesLine) -1;    numVertices = MIN(4, numVertices);  /* Maximum of 4 points */    AVCRawBinWriteInt32(psFile, numVertices );    for(i=0; i<numVertices; i++)    {        AVCRawBinWriteFloat(psFile, (float)psTxt->pasVertices[i+1].x);        AVCRawBinWriteFloat(psFile, (float)psTxt->pasVertices[i+1].y);    }    AVCRawBinWriteZeros(psFile, (4-numVertices)*4*2 + 28);    AVCRawBinWriteFloat(psFile, (float)psTxt->dHeight);    AVCRawBinWriteFloat(psFile, psTxt->f_1e2 );    AVCRawBinWriteInt32(psFile, psTxt->nSymbol );    AVCRawBinWriteInt32(psFile, psTxt->numChars );    if (nStrLen > 0)        AVCRawBinWritePaddedString(psFile, nStrLen, psTxt->pszText);    /*-----------------------------------------------------------------     * Write index entry (cnx.adf)     *----------------------------------------------------------------*/    if (psIndexFile)    {        _AVCBinWriteIndexEntry(psIndexFile, nCurPos, nRecSize);    }    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                          AVCBinWriteTxt() * * Write a TXT/TX6/TX7 (Annotation) structure to the file. * * The contents of the psTxt structure is assumed to be valid... this * function performs no validation on the consistency of what it is  * given as input. * * Returns 0 on success or -1 on error. * * If a problem happens, then CPLError() will be called by the lower-level * functions and CPLGetLastErrorNo() can be used to find out what happened. **********************************************************************/int AVCBinWriteTxt(AVCBinFile *psFile, AVCTxt *psTxt){    if (psFile->eFileType != AVCFileTXT && psFile->eFileType != AVCFileTX6)        return -1;    /* AVCCoverPC and AVCCoverWeird have a different TXT format than AVCCoverV7     */    if (psFile->eCoverType == AVCCoverPC ||         psFile->eCoverType == AVCCoverWeird)    {        return _AVCBinWritePCCoverageTxt(psFile->psRawBinFile, psTxt,                                         psFile->nPrecision,                                          psFile->psIndexFile);    }    else    {        return _AVCBinWriteTxt(psFile->psRawBinFile, psTxt,                               psFile->nPrecision, psFile->psIndexFile);    }}/*===================================================================== *                              RXP *====================================================================*//********************************************************************** *                          _AVCBinWriteRxp() * * (This function is for internal library use... external calls should * go to AVCBinWriteRxp() instead) * * Write a RXP (Region something...) structure to the file. * * The contents of the psRxp structure is assumed to be valid... this * function performs no validation on the consistency of what it is  * given as input. * * Returns 0 on success or -1 on error. **********************************************************************/int _AVCBinWriteRxp(AVCRawBinFile *psFile, AVCRxp *psRxp,                     int nPrecision){    AVCRawBinWriteInt32(psFile, psRxp->n1);    if (CPLGetLastErrorNo() != 0)        return -1;    AVCRawBinWriteInt32(psFile, psRxp->n2);    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                          AVCBinWriteRxp() * * Write a  RXP (Region something...) structure to the file. * * The contents of the psRxp structure is assumed to be valid... this * function performs no validation on the consistency of what it is  * given as input. * * Returns 0 on success or -1 on error. * * If a problem happens, then CPLError() will be called by the lower-level * functions and CPLGetLastErrorNo() can be used to find out what happened. **********************************************************************/int AVCBinWriteRxp(AVCBinFile *psFile, AVCRxp *psRxp){    if (psFile->eFileType != AVCFileRXP)        return -1;    return _AVCBinWriteRxp(psFile->psRawBinFile, psRxp,                           psFile->nPrecision);}/*===================================================================== *                              TABLES *====================================================================*//********************************************************************** *                          _AVCBinWriteArcDir() * * (This function is for internal library use... external calls should * go to AVCBinWriteCreateTable() instead) * * Write an ARC.DIR entry at the current position in file. * * The contents of the psTableDef structure is assumed to be valid... this * function performs no validation on the consistency of what it is  * given as input. * * Returns 0 on success or -1 on error. **********************************************************************/int _AVCBinWriteArcDir(AVCRawBinFile *psFile, AVCTableDef *psTableDef){    /* STRING values MUST be padded with spaces.     */    AVCRawBinWritePaddedString(psFile, 32, psTableDef->szTableName);    if (CPLGetLastErrorNo() != 0)        return -1;    AVCRawBinWritePaddedString(psFile, 8, psTableDef->szInfoFile);    AVCRawBinWriteInt16(psFile, psTableDef->numFields);    /* Record size must be a multiple of 2 bytes */    AVCRawBinWriteInt16(psFile, (GInt16)(((psTableDef->nRecSize+1)/2)*2));    /* ??? Unknown values ??? */    AVCRawBinWritePaddedString(psFile, 16, "                    ");    AVCRawBinWriteInt16(psFile, 132);    AVCRawBinWriteInt16(psFile, 0);    AVCRawBinWriteInt32(psFile, psTableDef->numRecords);    AVCRawBinWriteZeros(psFile, 10);    AVCRawBinWritePaddedString(psFile, 2, psTableDef->szExternal);    AVCRawBinWriteZeros(psFile, 238);    AVCRawBinWritePaddedString(psFile, 8, "                    ");    AVCRawBinWriteZeros(psFile, 54);    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                          _AVCBinWriteArcNit() * * (This function is for internal library use... external calls should * go to AVCBinWriteCreateTable() instead) * * Write an ARC####.NIT entry at the current position in file. * * The contents of the psTableDef structure is assumed to be valid... this * function performs no validation on the consistency of what it is  * given as input. * * Returns 0 on success or -1 on error. **********************************************************************/int _AVCBinWriteArcNit(AVCRawBinFile *psFile, AVCFieldInfo *psField){    /* STRING values MUST be padded with spaces.     */    AVCRawBinWritePaddedString(psFile, 16, psField->szName);    if (CPLGetLastErrorNo() != 0)        return -1;    AVCRawBinWriteInt16(psFile, psField->nSize);    AVCRawBinWriteInt16(psFile, psField->v2);    AVCRawBinWriteInt16(psFile, psField->nOffset);    AVCRawBinWriteInt16(psFile, psField->v4);    AVCRawBinWriteInt16(psFile, psField->v5);    AVCRawBinWriteInt16(psFile, psField->nFmtWidth);    AVCRawBinWriteInt16(psFile, psField->nFmtPrec);    AVCRawBinWriteInt16(psFile, psField->nType1);    AVCRawBinWriteInt16(psFile, psField->nType2);    AVCRawBinWriteInt16(psFile, psField->v10);    AVCRawBinWriteInt16(psFile, psField->v11);    AVCRawBinWriteInt16(psFile, psField->v12);    AVCRawBinWriteInt16(psFile, psField->v13);    AVCRawBinWritePaddedString(psFile, 16, psField->szAltName);    AVCRawBinWriteZeros(psFile, 56);    AVCRawBinWriteInt16(psFile, psField->nIndex);    AVCRawBinWriteZeros(psFile, 28);    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                     _AVCBinWriteCreateArcDirEntry() * * Add an entry in the ARC.DIR for the table defined in psSrcTableDef. * * If an entry with the same table name already exists then this entry

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -