Exemplo n.º 1
0
static void put_string_in_rgb_image(uint8_t *x, int w, int h,
		int posx, int posy, uint8_t *fg, uint8_t *bg, int kerning,
		struct bitmap_font *font, char *string)
{
	int posx0 = posx;
	while (1)
	{
		int c = *string++;
		if (!c) break;
		if (c == '\n') {
			posx = posx0;
			posy += font->height;
			continue;
		}
		if (c > 0 && c < font->number_of_glyphs)
		{
			for (int i = 0; i < font->width; i++)
			for (int j = 0; j < font->height; j++)
			{
				int ii = posx + i;
				int jj = posy + j;
				if (get_font_bit(font, c, i, j))
					put_pixel_rgb(x, w, h, ii, jj, fg);
				else
					put_pixel_rgb(x, w, h, ii, jj, bg);
			}
		}
		posx += font->width + kerning;
	}
}
Exemplo n.º 2
0
static void put_string_in_float_image(float *x, int w, int h, int pd,
		int posx, int posy, float *color, int kerning,
		struct bitmap_font *font, char *string)
{
	int posx0 = posx;
	while (1)
	{
		int c = *string++;
		if (!c) break;
		if (c == '\n') {
			posx = posx0;
			posy += font->height;
			continue;
		}
		if (c > 0 && c < font->number_of_glyphs)
		{
			//fprintf(stderr, "putting glyph \"%d\" '%c'\n", c, c);
			for (int i = 0; i < font->width; i++)
			for (int j = 0; j < font->height; j++)
				if (get_font_bit(font, c, i, j))
				{
					int ii = posx + i;
					int jj = posy + j;
					put_pixel(x, w, h, pd, ii, jj, color);
				}
			       	//else {
				//	float white[10] = {255};
				//	int ii = posx + i;
				//	int jj = posy + j;
				//	put_pixel(x, w, h, pd, ii, jj, white);
				//}
		}
		posx += font->width + kerning;
	}
}
Exemplo n.º 3
0
static void
put_char_in_rgb_image(uint8_t *rgb, int w, int h, struct bitmap_font *f,
		int posx, int posy, uint8_t *fg, uint8_t *bg, int c)
{
	if (c > 0 && c < f->number_of_glyphs)
		for (int i = 0; i < f->width; i++)
		for (int j = 0; j < f->height; j++)
		{
			int ii = posx + i;
			int jj = posy + j;
			if (get_font_bit(f, c, i, j))
				put_pixel_rgb(rgb, w, h, ii, jj, fg);
			else
				put_pixel_rgb(rgb, w, h, ii, jj, bg);
		}
}