Example #1
0
static PIX *
PtaDisplayRotate(PIX       *pixs,
                 l_float32  xc,
                 l_float32  yc)
{
l_int32  i, w, h;
PIX     *pix1, *pix2;
PTA     *pta1, *pta2, *pta3, *pta4;
PTAA    *ptaa;

        /* Save rotated sets of pixels */
    pta1 = ptaGetPixelsFromPix(pixs, NULL);
    ptaa = ptaaCreate(0);
    for (i = 0; i < 9; i++) {
        pta2 = ptaRotate(pta1, xc, yc, -0.8 + 0.2 * i);
        ptaaAddPta(ptaa, pta2, L_INSERT);
    }
    ptaDestroy(&pta1);

        /* Render them */
    pixGetDimensions(pixs, &w, &h, NULL);
    pix1 = pixCreate(w, h, 32);
    pixSetAll(pix1);
    pta3 = generatePtaFilledCircle(4);
    pta4 = ptaTranslate(pta3, xc, yc);
    pixRenderPtaArb(pix1, pta4, 255, 0, 0);  /* circle at rotation center */
    pix2 = pixDisplayPtaa(pix1, ptaa);  /* rotated sets */

    pixDestroy(&pix1);
    ptaDestroy(&pta3);
    ptaDestroy(&pta4);
    ptaaDestroy(&ptaa);
    return pix2;
}
Example #2
0
/*!
 *  boxaTranslate()
 *
 *      Input:  boxas
 *              transx  (x component of translation wrt. the origin)
 *              transy  (y component of translation wrt. the origin)
 *      Return: boxad  (translated boxas), or null on error
 *
 *  Notes;
 *      (1) See createMatrix2dTranslate() for details of transform.
 */
BOXA *
boxaTranslate(BOXA       *boxas,
              l_float32  transx,
              l_float32  transy)
{
PTA   *ptas, *ptad;
BOXA  *boxad;

    PROCNAME("boxaTranslate");

    if (!boxas)
        return (BOXA *)ERROR_PTR("boxas not defined", procName, NULL);

    ptas = boxaConvertToPta(boxas, 4);
    ptad = ptaTranslate(ptas, transx, transy);
    boxad = ptaConvertToBoxa(ptad, 4);
    ptaDestroy(&ptas);
    ptaDestroy(&ptad);
    return boxad;
}