src/jbclass.c
JBDATA *
jbDataSave(JBCLASSER  *classer)
{
l_int32  maxw, maxh;
JBDATA  *data;
PIX     *pix;

    PROCNAME("jbDataSave");

    if (!classer)
        return (JBDATA *)ERROR_PTR("classer not defined", procName, NULL);

        /* Write the templates into an array. */
    pixaSizeRange(classer->pixat, NULL, NULL, &maxw, &maxh);
    if ((pix = pixaDisplayOnLattice(classer->pixat, maxw + 1, maxh + 1))
            == NULL)
        return (JBDATA *)ERROR_PTR("data not made", procName, NULL);

    if ((data = (JBDATA *)CALLOC(1, sizeof(JBDATA))) == NULL)
        return (JBDATA *)ERROR_PTR("data not made", procName, NULL);
    data->pix = pix;
    data->npages = classer->npages;
    data->w = classer->w;
    data->h = classer->h;
    data->nclass = classer->nclass;
    data->latticew = maxw + 1;
    data->latticeh = maxh + 1;
    data->naclass = numaClone(classer->naclass);
    data->napage = numaClone(classer->napage);
    data->ptaul = ptaClone(classer->ptaul);

    return data;
}
/*!
 *  jbDataSave()
 *
 *      Input:  jbclasser
 *              latticew, latticeh (cell size used to store each
 *                  connected component in the composite)
 *      Return: jbdata, or null on error
 *
 *  Notes:
 *      (1) This routine stores the jbig2-type data required for
 *          generating a lossy jbig2 version of the image.
 *          It can be losslessly written to (and read from) two files.
 *      (2) It generates and stores the mosaic of templates.
 *      (3) It clones the Numa and Pta arrays, so these must all
 *          be destroyed by the caller.
 *      (4) Input 0 to use the default values for latticew and/or latticeh,
 */
jbDataSave()
Input:  jbclasser
latticew, latticeh (cell size used to store each
connected component in the composite)
Return: jbdata, or null on error

(1) This routine stores the jbig2-type data required for
generating a lossy jbig2 version of the image.
It can be losslessly written to (and read from) two files.
(2) It generates and stores the mosaic of templates.
(3) It clones the Numa and Pta arrays, so these must all
be destroyed by the caller.
(4) Input 0 to use the default values for latticew and/or latticeh.
jbDataSave () Input : jbclasser latticew latticeh ( cell size used to store each connected component in the composite ) Return : jbdata or null on error ( 1 ) This routine stores the jbig2 - type data required for generating a lossy jbig2 version of the image . It can be losslessly written to ( and read from ) two files . ( 2 ) It generates and stores the mosaic of templates . ( 3 ) It clones the Numa and Pta arrays so these must all be destroyed by the caller . ( 4 ) Input 0 to use the default values for latticew and / or latticeh .
JBDATA *
jbDataSave(JBCLASSER  *classer)
{
l_int32  maxw, maxh;
JBDATA  *data;
PIX     *pix;
    PROCNAME("jbDataSave");
    if (!classer)
        return (JBDATA *)ERROR_PTR("classer not defined", procName, NULL);
    pixaSizeRange(classer->pixat, NULL, NULL, &maxw, &maxh);
    if ((pix = pixaDisplayOnLattice(classer->pixat, maxw + 1, maxh + 1))
            == NULL)
        return (JBDATA *)ERROR_PTR("data not made", procName, NULL);
    if ((data = (JBDATA *)CALLOC(1, sizeof(JBDATA))) == NULL)
        return (JBDATA *)ERROR_PTR("data not made", procName, NULL);
    data->pix = pix;
    data->npages = classer->npages;
    data->w = classer->w;
    data->h = classer->h;
    data->nclass = classer->nclass;
    data->latticew = maxw + 1;
    data->latticeh = maxh + 1;
    data->naclass = numaClone(classer->naclass);
    data->napage = numaClone(classer->napage);
    data->ptaul = ptaClone(classer->ptaul);
    return data;
}
JBDATA * jbDataSave ( JBCLASSER * classer ) { l_int32 maxw , maxh ; JBDATA * data ; PIX * pix ; PROCNAME ( " " ) ; if ( ! classer ) return ( JBDATA * ) ERROR_PTR ( " " , procName , NULL ) ; pixaSizeRange ( classer -> pixat , NULL , NULL , & maxw , & maxh ) ; if ( ( pix = pixaDisplayOnLattice ( classer -> pixat , maxw + 1 , maxh + 1 ) ) == NULL ) return ( JBDATA * ) ERROR_PTR ( " " , procName , NULL ) ; if ( ( data = ( JBDATA * ) CALLOC ( 1 , sizeof ( JBDATA ) ) ) == NULL ) return ( JBDATA * ) ERROR_PTR ( " " , procName , NULL ) ; data -> pix = pix ; data -> npages = classer -> npages ; data -> w = classer -> w ; data -> h = classer -> h ; data -> nclass = classer -> nclass ; data -> latticew = maxw + 1 ; data -> latticeh = maxh + 1 ; data -> naclass = numaClone ( classer -> naclass ) ; data -> napage = numaClone ( classer -> napage ) ; data -> ptaul = ptaClone ( classer -> ptaul ) ; return data ; }
jbDataSave()
      Input:  jbclasser
              latticew, latticeh (cell size used to store each
                  connected component in the composite)
      Return: jbdata, or null on error
jbDataSave () Input : jbclasser latticew latticeh ( cell size used to store each connected component in the composite ) Return : jbdata or null on error
/* Write the templates into an array. */