Example #1
0
/**
 * f i l l _ b u f
 *
 * Fills in the buffer by reading a row of a bitmap from the character
 * font file.  The file pointer is assumed to be in the correct
 * position.
 */
void
fill_buf(register int wid, register int *buf)
{
    char    bitrow[FONTBUFSZ];
    register int     j;

    if ( font.ffdes == NULL )
	return;
    /* Read the row, rounding width up to nearest byte value. */
    if ( (int)fread( bitrow, (size_t)(wid / 8) + ((wid % 8 == 0) ? 0 : 1), 1, font.ffdes)
	 < 1
	)
    {
	(void) fprintf( stderr, "fill_buf() read failed!\n" );
	return;
    }

    /* For each bit in the row, set the array value to 1 if it's on.
       The bitx routine extracts the bit value.  Can't just use the
       j-th bit because the bytes are backwards.
    */
    for (j = 0; j < wid; j++)
	if (bitx (bitrow, (j & ~7) + (7 - (j & 7))))
	    buf[j + 2] = 1;
	else
	    buf[j + 2] = 0;

    /* Need two samples worth of background on either end to make the
       filtering come out right without special casing the
       filtering.
    */
    buf[0] = buf[1] = buf[wid + 2] = buf[wid + 3] = 0;
    return;
}
Example #2
0
/*
 Fills in the buffer by reading a row of a bitmap from the character
 font file.  The file pointer is assumed to be in the correct
 position.
*/
void
fill_buf(int wid, int *buf, char *bitrow)
{
    int j;

    /*
     * For each bit in the row, set the array value to 1 if it's
     * on. The bitx routine extracts the bit value.  Can't just use
     * the j-th bit because the bytes are backwards.
     */
    for (j = 0; j < wid; j++)
        if (bitx(bitrow, (j & ~7) + (7 - (j & 7))))
            buf[j + 2] = 1;
        else
            buf[j + 2] = 0;

    /*
     * Need two samples worth of background on either end to make the
     * filtering come out right without special casing the filtering.
     */
    buf[0] = buf[1] = buf[wid + 2] = buf[wid + 3] = 0;
}
Example #3
0
/*	d o _ c h a r ( )
	Outputs pixel representation of a chararcter by reading a row of a
	bitmap from the character font file.  The file pointer is assumed
	to be in the correct position.
*/
static void
do_char(int c, register int xpos, register int ypos)
{
    int     	up = font.dir[c].up / ir_aperture;
    int		left = font.dir[c].left / ir_aperture;
    static char	bitbuf[BUFFSIZ][BUFFSIZ];
    static RGBpixel	pixel;
    register int    h, i, j;
    int		k, x;
    for ( k = 0; k < font.height; k++ )
    {
	/* Read row, rounding width up to nearest byte value. */
	if ( fread( bitbuf[k], (size_t)font.width/8+(font.width % 8 == 0 ? 0 : 1), 1, font.ffdes )
	     != 1 )
	{
	    bu_log( "\"%s\" (%d) read of character from font failed.\n",
		    __FILE__, __LINE__
		);
	    return;
	}
    }
    for ( k = 0; k < font.height; k += ir_aperture, ypos-- )
    {
	x = xpos - left;
	for ( j = 0; j < font.width; j += ir_aperture, x++ )
	{
	    register int	sum;
	    fastf_t		weight;
	    /* The bitx routine extracts the bit value.
	       Can't just use the j-th bit because
	       the bytes are backwards. */
	    sum = 0;
	    for ( i = 0; i < ir_aperture; i++ )
		for ( h = 0; h < ir_aperture; h++ )
		    sum += bitx(	bitbuf[k+i],
					((j+h)&~7) + (7-((j+h)&7))
			) != 0;
	    weight = (fastf_t) sum / sample_sz;
	    if ( fb_seek( fbiop, x, ypos + up ) == -1 )
		continue;
	    if ( fb_rpixel( fbiop, (unsigned char *) pixel ) == -1 )
	    {
		bu_log( "\"%s\" (%d) read of pixel from <%d,%d> failed.\n",
			__FILE__, __LINE__, x, ypos
		    );
		return;
	    }
	    pixel[RED] = pixel[RED]*(1.0-weight) + FONTCOLOR_RED*weight;
	    pixel[GRN] = pixel[GRN]*(1.0-weight) + FONTCOLOR_GRN*weight;
	    pixel[BLU] = pixel[BLU]*(1.0-weight) + FONTCOLOR_BLU*weight;
	    if ( fb_seek( fbiop, x, ypos + up ) == -1 )
		continue;
	    if ( fb_wpixel( fbiop, (unsigned char *) pixel ) == -1 )
	    {
		bu_log( "\"%s\" (%d) write of pixel to <%d,%d> failed.\n",
			__FILE__, __LINE__, x, ypos
		    );
		return;
	    }
	}
    }
    return;
}