Подарок от UA3REO
// Convert image in
https://sourceforge.net/projects/lcd-image-converter/// preset name: Color R5G6B5
// data block size: 16 bit(s), uint16_t
// RLE compression enabled: yes !!!!!!!
// bits per pixel: 16
это-конвертер, а это декодер на С
Код:
[Выделить]void LCDDriver_printImage_RLECompressed(uint16_t x, uint16_t y, const tIMAGE *image, uint16_t transparent_color, uint16_t bg_color)
{
uint32_t pixels = image->width * image->height;
uint32_t i = 0;
uint32_t decoded = 0;
LCDDriver_SetCursorAreaPosition(x, y, image->width + x - 1, image->height + y - 1);
while (true)
{
if ((int16_t)image->data[i] < 0) // no repeats
{
uint16_t count = (-(int16_t)image->data[i]);
i++;
for (uint16_t p = 0; p < count; p++)
{
if (image->data[i] == transparent_color)
LCDDriver_SendData(bg_color);
else
LCDDriver_SendData(image->data[i]);
decoded++;
i++;
if (pixels <= decoded)
return;
}
}
else //repeats
{
uint16_t count = ((int16_t)image->data[i]);
i++;
for (uint16_t p = 0; p < count; p++)
{
if (image->data[i] == transparent_color)
LCDDriver_SendData(bg_color);
else
LCDDriver_SendData(image->data[i]);
decoded++;
if (pixels <= decoded)
return;
}
i++;
}
}
}
формат данных
Код:
[Выделить]static const tIMAGE IMAGES_logo_pd = {
.width = 262,
.height = 129,
.data = (const uint16_t[]) {
0x0093, 0xffff, 0xfff3, 0xf79e, 0x..........
запуск
Код:
[Выделить] LCDDriver_printImage_RLECompressed(((LCD_WIDTH - IMAGES_logo_pd.width) / 2), ((LCD_HEIGHT - IMAGES_logo_pd.height) / 2), &IMAGES_logo_pd, BG_COLOR, BG_COLOR);