20. Bitrow

This copies up to 16 bits of an integer to a row in a region. The leftmost x, y coordinate is provided, as well as the pattern, encoded as an unsigned short. The number of bits is also needed (up to 16).

<<funcdefs>>=
void btprnt_bitrow(btprnt_region *reg,
                   int x, int y,
                   int nbits,
                   unsigned short pat);
<<funcs>>=
void btprnt_bitrow(btprnt_region *reg,
                   int x, int y,
                   int nbits,
                   unsigned short pat)
{
    int i;
    if (nbits < 0) return;
    if (nbits > 16) nbits = 16;

    for (i = 0; i < nbits; i++) {
        btprnt_region_draw(reg,
                           x + i, y,
                           (pat & (1 << i)) >> i);
    }
}



prev | home | next