src/pixabasic.c
PIXA *
pixaCopy(PIXA    *pixa,
         l_int32  copyflag)
{
l_int32  i;
BOX     *boxc;
PIX     *pixc;
PIXA    *pixac;

    PROCNAME("pixaCopy");

    if (!pixa)
        return (PIXA *)ERROR_PTR("pixa not defined", procName, NULL);

    if (copyflag == L_CLONE) {
        pixaChangeRefcount(pixa, 1);
        return pixa;
    }

    if (copyflag != L_COPY && copyflag != L_COPY_CLONE)
        return (PIXA *)ERROR_PTR("invalid copyflag", procName, NULL);

    if ((pixac = pixaCreate(pixa->n)) == NULL)
        return (PIXA *)ERROR_PTR("pixac not made", procName, NULL);
    for (i = 0; i < pixa->n; i++) {
        if (copyflag == L_COPY) {
            pixc = pixaGetPix(pixa, i, L_COPY);
            boxc = pixaGetBox(pixa, i, L_COPY);
        }
        else {  /* copy-clone */
            pixc = pixaGetPix(pixa, i, L_CLONE);
            boxc = pixaGetBox(pixa, i, L_CLONE);
        }
        pixaAddPix(pixac, pixc, L_INSERT);
        pixaAddBox(pixac, boxc, L_INSERT);
    }

    return pixac;
}
/*!
 *  pixaCopy()
 *
 *      Input:  pixas
 *              copyflag:
 *                L_COPY makes a new pixa and copies each pix and each box
 *                L_CLONE gives a new ref-counted handle to the input pixa
 *                L_COPY_CLONE makes a new pixa and inserts clones of
 *                    all pix and boxes
 *      Return: new pixa, or null on error
 *
 *  Note: see pix.h for description of the copy types.
 */
pixaCopy()
Input:  pixas
copyflag:
L_COPY makes a new pixa and copies each pix and each box
L_CLONE gives a new ref-counted handle to the input pixa
L_COPY_CLONE makes a new pixa and inserts clones of
all pix and boxes
Return: new pixa, or null on error

see pix.h for description of the copy types.
pixaCopy () Input : pixas copyflag : L_COPY makes a new pixa and copies each pix and each box L_CLONE gives a new ref - counted handle to the input pixa L_COPY_CLONE makes a new pixa and inserts clones of all pix and boxes Return : new pixa or null on error see pix . h for description of the copy types .
PIXA *
pixaCopy(PIXA    *pixa,
         l_int32  copyflag)
{
l_int32  i;
BOX     *boxc;
PIX     *pixc;
PIXA    *pixac;
    PROCNAME("pixaCopy");
    if (!pixa)
        return (PIXA *)ERROR_PTR("pixa not defined", procName, NULL);
    if (copyflag == L_CLONE) {
        pixaChangeRefcount(pixa, 1);
        return pixa;
    }
    if (copyflag != L_COPY && copyflag != L_COPY_CLONE)
        return (PIXA *)ERROR_PTR("invalid copyflag", procName, NULL);
    if ((pixac = pixaCreate(pixa->n)) == NULL)
        return (PIXA *)ERROR_PTR("pixac not made", procName, NULL);
    for (i = 0; i < pixa->n; i++) {
        if (copyflag == L_COPY) {
            pixc = pixaGetPix(pixa, i, L_COPY);
            boxc = pixaGetBox(pixa, i, L_COPY);
        }
        else {  
            pixc = pixaGetPix(pixa, i, L_CLONE);
            boxc = pixaGetBox(pixa, i, L_CLONE);
        }
        pixaAddPix(pixac, pixc, L_INSERT);
        pixaAddBox(pixac, boxc, L_INSERT);
    }
    return pixac;
}
PIXA * pixaCopy ( PIXA * pixa , l_int32 copyflag ) { l_int32 i ; BOX * boxc ; PIX * pixc ; PIXA * pixac ; PROCNAME ( " " ) ; if ( ! pixa ) return ( PIXA * ) ERROR_PTR ( " " , procName , NULL ) ; if ( copyflag == L_CLONE ) { pixaChangeRefcount ( pixa , 1 ) ; return pixa ; } if ( copyflag != L_COPY && copyflag != L_COPY_CLONE ) return ( PIXA * ) ERROR_PTR ( " " , procName , NULL ) ; if ( ( pixac = pixaCreate ( pixa -> n ) ) == NULL ) return ( PIXA * ) ERROR_PTR ( " " , procName , NULL ) ; for ( i = 0 ; i < pixa -> n ; i ++ ) { if ( copyflag == L_COPY ) { pixc = pixaGetPix ( pixa , i , L_COPY ) ; boxc = pixaGetBox ( pixa , i , L_COPY ) ; } else { pixc = pixaGetPix ( pixa , i , L_CLONE ) ; boxc = pixaGetBox ( pixa , i , L_CLONE ) ; } pixaAddPix ( pixac , pixc , L_INSERT ) ; pixaAddBox ( pixac , boxc , L_INSERT ) ; } return pixac ; }
pixaCopy()
      Input:  pixas
              copyflag:
                L_COPY makes a new pixa and copies each pix and each box
                L_CLONE gives a new ref-counted handle to the input pixa
                L_COPY_CLONE makes a new pixa and inserts clones of
                    all pix and boxes
      Return: new pixa, or null on error
pixaCopy () Input : pixas copyflag : L_COPY makes a new pixa and copies each pix and each box L_CLONE gives a new ref - counted handle to the input pixa L_COPY_CLONE makes a new pixa and inserts clones of all pix and boxes Return : new pixa or null on error
/* copy-clone */