1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/shentqlf-eBox_Framework

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
gui_bitmap.cpp 3 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
shentqlf Отправлено 6 лет назад 7e1aa59
#include "graphic.h"
// Draw a 1-bit image (bitmap) at the specified (x,y) position from the
// provided bitmap buffer (must be PROGMEM memory) using the specified
// foreground color (unset bits are transparent).
void Graphic::drawBitmap(int16_t x, int16_t y,
const uint8_t *bitmap, int16_t w, int16_t h, uint32_t color)
{
int16_t i, j, byteWidth = (w + 7) / 8;
uint8_t byte;
for(j = 0; j < h; j++)
{
for(i = 0; i < w; i++)
{
if(i & 7) byte <<= 1;
else byte = *(bitmap + j * byteWidth + i / 8);
if(byte & 0x80) draw_pixel(x + i, y + j, color);
}
}
}
// Draw a 1-bit image (bitmap) at the specified (x,y) position from the
// provided bitmap buffer (must be PROGMEM memory) using the specified
// foreground (for set bits) and background (for clear bits) colors.
void Graphic::drawBitmap(int16_t x, int16_t y,
const uint8_t *bitmap, int16_t w, int16_t h, uint32_t color, uint16_t bg)
{
int16_t i, j, byteWidth = (w + 7) / 8;
uint8_t byte;
for(j = 0; j < h; j++)
{
for(i = 0; i < w; i++ )
{
if(i & 7) byte <<= 1;
else byte = *(bitmap + j * byteWidth + i / 8);
if(byte & 0x80) draw_pixel(x + i, y + j, color);
else draw_pixel(x + i, y + j, bg);
}
}
}
// drawBitmap() variant for RAM-resident (not PROGMEM) bitmaps.
void Graphic::drawBitmap(int16_t x, int16_t y,
uint8_t *bitmap, int16_t w, int16_t h, uint32_t color)
{
int16_t i, j, byteWidth = (w + 7) / 8;
uint8_t byte;
for(j = 0; j < h; j++)
{
for(i = 0; i < w; i++ )
{
if(i & 7) byte <<= 1;
else byte = bitmap[j * byteWidth + i / 8];
if(byte & 0x80) draw_pixel(x + i, y + j, color);
}
}
}
// drawBitmap() variant w/background for RAM-resident (not PROGMEM) bitmaps.
void Graphic::drawBitmap(int16_t x, int16_t y,
uint8_t *bitmap, int16_t w, int16_t h, uint32_t color, uint16_t bg)
{
int16_t i, j, byteWidth = (w + 7) / 8;
uint8_t byte;
for(j = 0; j < h; j++)
{
for(i = 0; i < w; i++ )
{
if(i & 7) byte <<= 1;
else byte = bitmap[j * byteWidth + i / 8];
if(byte & 0x80) draw_pixel(x + i, y + j, color);
else draw_pixel(x + i, y + j, bg);
}
}
}
//Draw XBitMap Files (*.xbm), exported from GIMP,
//Usage: Export from GIMP to *.xbm, rename *.xbm to *.c and open in editor.
//C Array can be directly used with this function
void Graphic::drawXBitmap(int16_t x, int16_t y,
const uint8_t *bitmap, int16_t w, int16_t h, uint32_t color)
{
int16_t i, j, byteWidth = (w + 7) / 8;
uint8_t byte;
for(j = 0; j < h; j++)
{
for(i = 0; i < w; i++ )
{
if(i & 7) byte >>= 1;
else byte = *(bitmap + j * byteWidth + i / 8);
if(byte & 0x01) draw_pixel(x + i, y + j, color);
}
}
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/shentqlf-eBox_Framework.git
git@gitlife.ru:oschina-mirror/shentqlf-eBox_Framework.git
oschina-mirror
shentqlf-eBox_Framework
shentqlf-eBox_Framework
master