src/pixabasic.c
l_int32
pixaInitFull(PIXA  *pixa,
             PIX   *pix,
             BOX   *box)
{
l_int32  i, n;
PIX     *pixt;

    PROCNAME("pixaInitFull");

    if (!pixa)
        return ERROR_INT("pixa not defined", procName, 1);
    if (!pix)
        return ERROR_INT("pix not defined", procName, 1);

    n = pixa->nalloc;
    pixa->n = n;
    for (i = 0; i < n; i++) {
        pixt = pixCopy(NULL, pix);
        pixaReplacePix(pixa, i, pixt, NULL);
    }
    if (box)
        boxaInitFull(pixa->boxa, box);

    return 0;
}
/*!
 *  pixaInitFull()
 *
 *      Input:  pixa (typically empty)
 *              pix (to be replicated into the entire pixa ptr array)
 *              box (<optional> to be replicated into the entire boxa ptr array)
 *      Return: 0 if OK, 1 on error
 *
 *  Notes:
 *      (1) This initializes a pixa by filling up the entire pix ptr array
 *          with copies of @pix.  Any existing pix are destroyed.
 *          It also fills the boxa with copies of @box.
 *          After this oepration, the numbers of pix and boxes are equal to
 *          the number of allocated ptrs.
 *      (2) Note that we use pixaReplacePix() instead of pixaInsertPix().
 *          They both have the same effect when inserting into a NULL ptr
 *          in the pixa ptr array:
 *      (3) Example usage.  This function is useful to prepare for a
 *          random insertion (or replacement) of pix into a pixa.
 *          To randomly insert pix into a pixa, up to some index "max":
 *             Pixa *pixa = pixaCreate(max);
 *             Pix *pix = pixCreate(1, 1, 1);  // little memory
 *             Box *box = boxCreate(...);
 *             pixaInitFull(pixa, pix, box);
 *          An existing pixa with a smaller ptr array can also be reused:
 *             pixaExtendArrayToSize(pixa, max);
 *             Pix *pix = pixCreate(...);
 *             Box *box = boxCreate(...);
 *             pixaInitFull(pixa, pix, box);
 *          For these situations, the pix should be small and disposable.
 *          The initialization allows the pixa to always be properly
 *          filled, even if all pix (and boxes) are not later replaced.
 */
pixaInitFull()
Input:  pixa (typically empty)
pix (to be replicated into the entire pixa ptr array)
box ( to be replicated into the entire boxa ptr array)
Return: 0 if OK, 1 on error

(1) This initializes a pixa by filling up the entire pix ptr array
with copies of @pix.  Any existing pix are destroyed.
It also fills the boxa with copies of @box.
After this oepration, the numbers of pix and boxes are equal to
the number of allocated ptrs.
(2) Note that we use pixaReplacePix() instead of pixaInsertPix().
They both have the same effect when inserting into a NULL ptr
in the pixa ptr array:
(3) Example usage.  This function is useful to prepare for a
random insertion (or replacement) of pix into a pixa.
pixaInitFull () Input : pixa ( typically empty ) pix ( to be replicated into the entire pixa ptr array ) box ( to be replicated into the entire boxa ptr array ) Return : 0 if OK 1 on error ( 1 ) This initializes a pixa by filling up the entire pix ptr array with copies of @pix . Any existing pix are destroyed . It also fills the boxa with copies of @box . After this oepration the numbers of pix and boxes are equal to the number of allocated ptrs . ( 2 ) Note that we use pixaReplacePix () instead of pixaInsertPix () . They both have the same effect when inserting into a NULL ptr in the pixa ptr array : ( 3 ) Example usage . This function is useful to prepare for a random insertion ( or replacement ) of pix into a pixa .
l_int32
pixaInitFull(PIXA  *pixa,
             PIX   *pix,
             BOX   *box)
{
l_int32  i, n;
PIX     *pixt;
    PROCNAME("pixaInitFull");
    if (!pixa)
        return ERROR_INT("pixa not defined", procName, 1);
    if (!pix)
        return ERROR_INT("pix not defined", procName, 1);
    n = pixa->nalloc;
    pixa->n = n;
    for (i = 0; i < n; i++) {
        pixt = pixCopy(NULL, pix);
        pixaReplacePix(pixa, i, pixt, NULL);
    }
    if (box)
        boxaInitFull(pixa->boxa, box);
    return 0;
}
l_int32 pixaInitFull ( PIXA * pixa , PIX * pix , BOX * box ) { l_int32 i , n ; PIX * pixt ; PROCNAME ( " " ) ; if ( ! pixa ) return ERROR_INT ( " " , procName , 1 ) ; if ( ! pix ) return ERROR_INT ( " " , procName , 1 ) ; n = pixa -> nalloc ; pixa -> n = n ; for ( i = 0 ; i < n ; i ++ ) { pixt = pixCopy ( NULL , pix ) ; pixaReplacePix ( pixa , i , pixt , NULL ) ; } if ( box ) boxaInitFull ( pixa -> boxa , box ) ; return 0 ; }
pixaInitFull()
      Input:  pixa (typically empty)
              pix (to be replicated into the entire pixa ptr array)
              box (<optional> to be replicated into the entire boxa ptr array)
      Return: 0 if OK, 1 on error
pixaInitFull () Input : pixa ( typically empty ) pix ( to be replicated into the entire pixa ptr array ) box ( <optional > to be replicated into the entire boxa ptr array ) Return : 0 if OK 1 on error