Exemplo n.º 1
0
static void
adaptRowFormat(struct pam * const inpamP,
               struct pam * const outpamP,
               tuple *      const tuplerow) {
/*----------------------------------------------------------------------------
   Convert the row in 'tuplerow', which is in a format described by
   *inpamP, to the format described by *outpamP.

   'tuplerow' must have enough allocated depth to do this.
-----------------------------------------------------------------------------*/
    assert(outpamP->visual);
    assert(inpamP->visual);

    pnm_scaletuplerow(inpamP, tuplerow, tuplerow, outpamP->maxval);

    if (outpamP->color_depth == 3) {
        if (outpamP->have_opacity)
            pnm_makerowrgba(inpamP, tuplerow);
        else
            pnm_makerowrgb(inpamP, tuplerow);
    } else {
        if (outpamP->have_opacity)
            pnm_addopacityrow(inpamP, tuplerow);
    }
}
Exemplo n.º 2
0
static void
adaptRowToOutputFormat(struct pam * const inpamP,
                       tuple *      const tuplerow,
                       struct pam * const outpamP) {
/*----------------------------------------------------------------------------
   Convert the row in 'tuplerow', which is in a format described by
   *inpamP, to the format described by *outpamP.

   'tuplerow' must have enough allocated depth to do this.
-----------------------------------------------------------------------------*/
    pnm_scaletuplerow(inpamP, tuplerow, tuplerow, outpamP->maxval);

    if (strncmp(outpamP->tuple_type, "RGB", 3) == 0)
        pnm_makerowrgb(inpamP, tuplerow);
}
Exemplo n.º 3
0
static void
convertRowStraight(struct pam *            const inpamP,
                   struct pam *            const outpamP, 
                   tuple                         inrow[],
                   depthAdjustment         const depthAdjustment,
                   tupletable              const colormap,
                   struct colormapFinder * const colorFinderP,
                   tuplehash               const colorhash, 
                   bool *                  const usehashP,
                   tuple                   const defaultColor,
                   tuple                         outrow[],
                   unsigned int *          const missingCountP) {
/*----------------------------------------------------------------------------
  Like convertRow(), compute outrow[] from inrow[], replacing each pixel with
  the new colors.  Do a straight pixel for pixel remap; no dithering.

  Return the number of pixels that were not matched in the color map as
  *missingCountP.

  *colorFinderP is a color finder based on 'colormap' -- it tells us what
  index of 'colormap' corresponds to a certain color.
-----------------------------------------------------------------------------*/
    unsigned int col;
    unsigned int missingCount;
    
    /* The following modify tuplerow, to make it consistent with
     *outpamP instead of *inpamP.
     */
    assert(outpamP->allocation_depth >= inpamP->depth);

    pnm_scaletuplerow(inpamP, outrow, inrow, outpamP->maxval);

    adjustDepthRow(outrow, outpamP->width, depthAdjustment);

    missingCount = 0;  /* initial value */
    
    for (col = 0; col < outpamP->width; ++col) {
        bool missing;
        mapTuple(outpamP, outrow[col], defaultColor,
                 colormap, colorFinderP,
                 colorhash, usehashP, outrow[col], &missing);

        if (missing)
            ++missingCount;
    }

    *missingCountP = missingCount;
}