xbm
This commit is contained in:
parent
864657b244
commit
db0cafb67a
|
@ -447,6 +447,7 @@ void u8g2_SetDrawColor(u8g2_t *u8g2, uint8_t color) U8G2_NOINLINE; /* u8g: u8g_
|
|||
/*==========================================*/
|
||||
/* u8g2_bitmap.c */
|
||||
void u8g2_DrawHBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t *b);
|
||||
void u8g2_DrawXBM(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, const uint8_t *bitmap);
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
|
|
|
@ -71,8 +71,38 @@ void u8g2_DrawHBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t le
|
|||
u8g2->draw_color = color;
|
||||
}
|
||||
|
||||
void u8g2_DrawHXBM(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t *b)
|
||||
{
|
||||
uint8_t mask;
|
||||
uint8_t color = u8g2->draw_color;
|
||||
uint8_t ncolor = 1-color;
|
||||
#ifdef U8G2_WITH_INTERSECTION
|
||||
if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
|
||||
return;
|
||||
#endif /* U8G2_WITH_INTERSECTION */
|
||||
|
||||
mask = 1;
|
||||
while(len > 0)
|
||||
{
|
||||
if ( *b & mask )
|
||||
u8g2->draw_color = color;
|
||||
else
|
||||
u8g2->draw_color = ncolor;
|
||||
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
|
||||
x++;
|
||||
mask <<= 1;
|
||||
if ( mask == 0 )
|
||||
{
|
||||
mask = 1;
|
||||
b++;
|
||||
}
|
||||
len--;
|
||||
}
|
||||
u8g2->draw_color = color;
|
||||
}
|
||||
|
||||
void u8g_DrawBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, const uint8_t *bitmap)
|
||||
|
||||
void u8g2_DrawXBM(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, const uint8_t *bitmap)
|
||||
{
|
||||
u8g2_uint_t blen;
|
||||
blen = w;
|
||||
|
@ -85,7 +115,7 @@ void u8g_DrawBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u
|
|||
|
||||
while( h > 0 )
|
||||
{
|
||||
u8g2_DrawHBitmap(u8g2, x, y, w, bitmap);
|
||||
u8g2_DrawHXBM(u8g2, x, y, w, bitmap);
|
||||
bitmap += blen;
|
||||
y++;
|
||||
h--;
|
||||
|
|
|
@ -6,7 +6,17 @@
|
|||
|
||||
u8g2_t u8g2;
|
||||
|
||||
uint8_t b[2] = { 0x55, 0x55 };
|
||||
static unsigned char b[] = {
|
||||
0xff, 0xff, 0x07, 0x01, 0x00, 0x04, 0x01, 0x00, 0x04, 0x01, 0x08, 0x04,
|
||||
0xe1, 0x1e, 0x04, 0xb1, 0x13, 0x04, 0x11, 0x11, 0x04, 0x11, 0x79, 0x04,
|
||||
0xf1, 0x4f, 0x04, 0x99, 0xc4, 0x04, 0x89, 0x7f, 0x04, 0xc9, 0x38, 0x04,
|
||||
0xf1, 0x08, 0x04, 0x81, 0x08, 0x04, 0x81, 0x0f, 0x04, 0x01, 0xe2, 0x04,
|
||||
0x01, 0xda, 0x04, 0x01, 0xba, 0x04, 0x01, 0x9e, 0x04, 0x01, 0x4e, 0x04,
|
||||
0x01, 0x7e, 0x04, 0x01, 0x1e, 0x04, 0x01, 0x06, 0x04, 0x01, 0x06, 0x04,
|
||||
0x01, 0x06, 0x04, 0x01, 0x02, 0x04, 0x01, 0x00, 0x04, 0x01, 0x00, 0x04,
|
||||
0xff, 0xff, 0x07 };
|
||||
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
@ -23,8 +33,8 @@ int main(void)
|
|||
u8g2_FirstPage(&u8g2);
|
||||
do
|
||||
{
|
||||
u8g2_DrawHBitmap(&u8g2, 0, 0, 10, b);
|
||||
u8g2_DrawStr(&u8g2, 30, 20, "HBitmap");
|
||||
u8g2_DrawXBM(&u8g2, 1, 1, 19, 29, b);
|
||||
u8g2_DrawStr(&u8g2, 30, 20, "XBM");
|
||||
} while( u8g2_NextPage(&u8g2) );
|
||||
|
||||
utf8_show();
|
||||
|
|
Loading…
Reference in New Issue