IPB

Здравствуйте, гость ( Вход | Регистрация )

 
Ответить в эту темуОткрыть новую тему
> конвертер бинарных файлов в массивы C / C++
SuperMax
сообщение 4.8.2021, 11:34
Сообщение #1


Администратор
*****

Группа: Root Admin
Сообщений: 6 141
Регистрация: 7.1.2006
Из: Красноярск
Пользователь №: 1



Задача простая - есть бинарный файл небольшого объема который надо быстро затащить как массив в C или C++

под винду х64
Прикрепленный файл  bin2array.exe ( 129.61 килобайт ) Кол-во скачиваний: 153


под линукс х64
Прикрепленный файл  bin2array_lin.exe ( 7.54 килобайт ) Кол-во скачиваний: 148



converter binary file to array for c/cpp
usage:
bin2array input.file output.file
©Maxiol 2021

пример результата - конвертация шрифта БКшки

Код

const unsigned char bkfont[] =
{
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
    ,0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x08,0x00,0x00
    ,0x00,0x24,0x12,0x09,0x00,0x00,0x00,0x00,0x00,0x00
    ,0x00,0x14,0x14,0x3e,0x14,0x3e,0x14,0x14,0x00,0x00
    ,0x08,0x3e,0x0a,0x0a,0x3e,0x28,0x28,0x3e,0x08,0x00
    ,0x00,0x06,0x26,0x10,0x08,0x04,0x32,0x30,0x00,0x00
    ,0x00,0x1c,0x14,0x14,0x0c,0x2a,0x12,0x2e,0x00,0x00
    ,0x00,0x10,0x08,0x04,0x00,0x00,0x00,0x00,0x00,0x00
    ,0x00,0x10,0x08,0x04,0x04,0x04,0x08,0x10,0x00,0x00
    ,0x00,0x04,0x08,0x10,0x10,0x10,0x08,0x04,0x00,0x00
    ,0x00,0x00,0x08,0x2a,0x1c,0x2a,0x08,0x00,0x00,0x00
    ,0x00,0x00,0x08,0x08,0x3e,0x08,0x08,0x00,0x00,0x00
    ,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x08,0x0c
    ,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x00,0x00
    ,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x00,0x00
    ,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00,0x00
    ,0x00,0x3e,0x22,0x32,0x2a,0x26,0x22,0x3e,0x00,0x00
    ,0x00,0x08,0x0c,0x08,0x08,0x08,0x08,0x3e,0x00,0x00
    ,0x00,0x3e,0x20,0x20,0x3e,0x02,0x02,0x3e,0x00,0x00
    ,0x00,0x3e,0x20,0x20,0x38,0x20,0x20,0x3e,0x00,0x00
    ,0x00,0x30,0x28,0x24,0x22,0x3e,0x20,0x20,0x00,0x00
    ,0x00,0x3e,0x02,0x02,0x3e,0x20,0x20,0x3e,0x00,0x00
    ,0x00,0x3e,0x02,0x02,0x3e,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x3e,0x20,0x10,0x08,0x08,0x08,0x08,0x00,0x00
    ,0x00,0x3e,0x22,0x22,0x3e,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x3e,0x22,0x22,0x3e,0x20,0x20,0x3e,0x00,0x00
    ,0x00,0x00,0x00,0x0c,0x0c,0x00,0x0c,0x0c,0x00,0x00
    ,0x00,0x00,0x00,0x0c,0x0c,0x00,0x0c,0x0c,0x08,0x0c
    ,0x00,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x00,0x3e,0x00,0x00,0x00,0x00
    ,0x00,0x04,0x08,0x10,0x20,0x10,0x08,0x04,0x00,0x00
    ,0x00,0x3e,0x22,0x20,0x38,0x08,0x00,0x08,0x00,0x00
    ,0x00,0x3e,0x22,0x3a,0x2a,0x3a,0x02,0x3e,0x00,0x00
    ,0x00,0x3e,0x22,0x22,0x22,0x3e,0x22,0x22,0x00,0x00
    ,0x00,0x3e,0x22,0x22,0x1e,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x3e,0x02,0x02,0x02,0x02,0x02,0x3e,0x00,0x00
    ,0x00,0x3e,0x24,0x24,0x24,0x24,0x24,0x3e,0x00,0x00
    ,0x00,0x3e,0x02,0x02,0x1e,0x02,0x02,0x3e,0x00,0x00
    ,0x00,0x3e,0x02,0x02,0x1e,0x02,0x02,0x02,0x00,0x00
    ,0x00,0x3e,0x22,0x02,0x02,0x32,0x22,0x3e,0x00,0x00
    ,0x00,0x22,0x22,0x22,0x3e,0x22,0x22,0x22,0x00,0x00
    ,0x00,0x1c,0x08,0x08,0x08,0x08,0x08,0x1c,0x00,0x00
    ,0x00,0x38,0x10,0x10,0x10,0x10,0x12,0x1e,0x00,0x00
    ,0x00,0x22,0x22,0x22,0x1e,0x22,0x22,0x22,0x00,0x00
    ,0x00,0x02,0x02,0x02,0x02,0x02,0x02,0x3e,0x00,0x00
    ,0x00,0x1e,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x00,0x00
    ,0x00,0x1e,0x22,0x22,0x22,0x22,0x22,0x22,0x00,0x00
    ,0x00,0x3e,0x22,0x22,0x22,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x3e,0x22,0x22,0x3e,0x02,0x02,0x02,0x00,0x00
    ,0x00,0x3e,0x22,0x22,0x22,0x2a,0x12,0x2e,0x00,0x00
    ,0x00,0x3e,0x22,0x22,0x3e,0x12,0x22,0x22,0x00,0x00
    ,0x00,0x3e,0x22,0x02,0x3e,0x20,0x22,0x3e,0x00,0x00
    ,0x00,0x3e,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00
    ,0x00,0x22,0x22,0x22,0x22,0x22,0x22,0x3c,0x00,0x00
    ,0x00,0x22,0x22,0x22,0x22,0x22,0x14,0x08,0x00,0x00
    ,0x00,0x22,0x22,0x22,0x2a,0x2a,0x2a,0x14,0x00,0x00
    ,0x00,0x22,0x22,0x22,0x1c,0x22,0x22,0x22,0x00,0x00
    ,0x00,0x22,0x22,0x22,0x1c,0x08,0x08,0x08,0x00,0x00
    ,0x00,0x3e,0x20,0x10,0x08,0x04,0x02,0x3e,0x00,0x00
    ,0x00,0x1c,0x04,0x04,0x04,0x04,0x04,0x1c,0x00,0x00
    ,0x00,0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00,0x00
    ,0x00,0x1c,0x10,0x10,0x10,0x10,0x10,0x1c,0x00,0x00
    ,0x00,0x08,0x14,0x22,0x00,0x00,0x00,0x00,0x00,0x00
    ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00
    ,0x00,0x04,0x08,0x10,0x00,0x00,0x00,0x00,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x20,0x3e,0x22,0x7e,0x00,0x00
    ,0x00,0x02,0x02,0x3e,0x22,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x02,0x02,0x02,0x3e,0x00,0x00
    ,0x00,0x20,0x20,0x3e,0x22,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x22,0x3e,0x02,0x3e,0x00,0x00
    ,0x00,0x3c,0x24,0x04,0x0e,0x04,0x04,0x04,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x22,0x22,0x22,0x3e,0x20,0x3e
    ,0x00,0x02,0x02,0x3e,0x22,0x22,0x22,0x22,0x00,0x00
    ,0x00,0x08,0x00,0x0c,0x08,0x08,0x08,0x1c,0x00,0x00
    ,0x00,0x10,0x00,0x10,0x10,0x10,0x10,0x10,0x12,0x1e
    ,0x00,0x02,0x02,0x22,0x22,0x1e,0x22,0x22,0x00,0x00
    ,0x00,0x0c,0x08,0x08,0x08,0x08,0x08,0x1c,0x00,0x00
    ,0x00,0x00,0x00,0x1e,0x2a,0x2a,0x2a,0x2a,0x00,0x00
    ,0x00,0x00,0x00,0x1e,0x22,0x22,0x22,0x22,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x22,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x22,0x22,0x22,0x3e,0x02,0x02
    ,0x00,0x00,0x00,0x3e,0x22,0x22,0x22,0x3e,0x20,0x20
    ,0x00,0x00,0x00,0x3e,0x22,0x02,0x02,0x02,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x02,0x3e,0x20,0x3e,0x00,0x00
    ,0x00,0x04,0x04,0x0e,0x04,0x04,0x24,0x3c,0x00,0x00
    ,0x00,0x00,0x00,0x22,0x22,0x22,0x22,0x3c,0x00,0x00
    ,0x00,0x00,0x00,0x22,0x22,0x22,0x14,0x08,0x00,0x00
    ,0x00,0x00,0x00,0x22,0x22,0x2a,0x2a,0x14,0x00,0x00
    ,0x00,0x00,0x00,0x22,0x22,0x1c,0x22,0x22,0x00,0x00
    ,0x00,0x00,0x00,0x22,0x22,0x22,0x22,0x3e,0x20,0x3e
    ,0x00,0x00,0x00,0x3e,0x10,0x08,0x04,0x3e,0x00,0x00
    ,0x00,0x20,0x30,0x38,0x3c,0x3c,0x38,0x30,0x20,0x00
    ,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00
    ,0x00,0x04,0x0c,0x1c,0x3c,0x3c,0x1c,0x0c,0x04,0x00
    ,0x3e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
    ,0x00,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x00,0x00
    ,0x3c,0x42,0x81,0xbd,0x85,0x85,0xbd,0x81,0x42,0x3c
    ,0x08,0x08,0x08,0x08,0xff,0x00,0x00,0x00,0x00,0x00
    ,0x00,0x00,0x00,0xfc,0x04,0xf4,0x14,0x14,0x14,0x14
    ,0x00,0x00,0x00,0x00,0x0f,0x08,0x08,0x08,0x08,0x08
    ,0x08,0x08,0x08,0x0f,0x08,0x0f,0x08,0x08,0x08,0x08
    ,0x08,0x08,0x08,0x08,0xf8,0x08,0x08,0x08,0x08,0x08
    ,0x08,0x08,0x08,0x08,0xf8,0x00,0x00,0x00,0x00,0x00
    ,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00
    ,0x00,0x00,0x00,0xff,0x00,0xff,0x08,0x08,0x08,0x08
    ,0x00,0x00,0x00,0x1f,0x10,0x17,0x14,0x14,0x14,0x14
    ,0x00,0x00,0x00,0x00,0xf8,0x08,0x08,0x08,0x08,0x08
    ,0x00,0x00,0x00,0x00,0xff,0x08,0x08,0x08,0x08,0x08
    ,0x14,0x14,0x14,0x14,0xff,0x00,0x00,0x00,0x00,0x00
    ,0x00,0x08,0x08,0x08,0x08,0x2a,0x1c,0x08,0x00,0x00
    ,0x08,0x08,0x08,0x08,0xff,0x08,0x08,0x08,0x08,0x08
    ,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14
    ,0x08,0x08,0x08,0x08,0x0f,0x08,0x08,0x08,0x08,0x08
    ,0x00,0x00,0x08,0x04,0x7e,0x04,0x08,0x00,0x00,0x00
    ,0x14,0x14,0x14,0xf7,0x00,0xf7,0x14,0x14,0x14,0x14
    ,0x00,0x08,0x1c,0x2a,0x08,0x08,0x08,0x08,0x00,0x00
    ,0x14,0x14,0x14,0xf4,0x04,0xfc,0x00,0x00,0x00,0x00
    ,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00
    ,0x14,0x14,0x14,0x14,0xf7,0x14,0x14,0x14,0x14,0x14
    ,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08
    ,0x14,0x14,0x14,0x17,0x10,0x1f,0x00,0x00,0x00,0x00
    ,0x08,0x08,0x08,0x08,0x0f,0x00,0x00,0x00,0x00,0x00
    ,0x08,0x08,0x08,0xff,0x00,0xff,0x08,0x08,0x08,0x08
    ,0x00,0x00,0x00,0x00,0xff,0x14,0x14,0x14,0x14,0x14
    ,0x08,0x08,0x08,0xff,0x00,0xff,0x00,0x00,0x00,0x00
    ,0x08,0x08,0x08,0xf8,0x08,0xf8,0x08,0x08,0x08,0x08
    ,0x00,0x00,0x10,0x20,0x7e,0x20,0x10,0x00,0x00,0x00
    ,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55
    ,0x00,0x00,0x00,0x3a,0x2a,0x2e,0x2a,0x3a,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x20,0x3e,0x22,0x7e,0x00,0x00
    ,0x00,0x00,0x3e,0x02,0x3e,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x00,0x00,0x12,0x12,0x12,0x12,0x3e,0x20,0x00
    ,0x00,0x00,0x3e,0x20,0x3e,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x22,0x3e,0x02,0x3e,0x00,0x00
    ,0x00,0x00,0x08,0x3e,0x2a,0x2a,0x2a,0x3e,0x08,0x08
    ,0x00,0x00,0x00,0x3e,0x02,0x02,0x02,0x02,0x00,0x00
    ,0x00,0x00,0x00,0x22,0x22,0x1c,0x22,0x22,0x00,0x00
    ,0x00,0x00,0x00,0x22,0x32,0x2a,0x26,0x22,0x00,0x00
    ,0x00,0x08,0x08,0x22,0x32,0x2a,0x26,0x22,0x00,0x00
    ,0x00,0x00,0x00,0x22,0x12,0x0e,0x12,0x22,0x00,0x00
    ,0x00,0x00,0x00,0x20,0x30,0x28,0x24,0x22,0x00,0x00
    ,0x00,0x00,0x00,0x28,0x3c,0x2a,0x2a,0x2a,0x00,0x00
    ,0x00,0x00,0x00,0x22,0x22,0x3e,0x22,0x22,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x22,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x22,0x22,0x22,0x22,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x22,0x3e,0x24,0x22,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x22,0x22,0x22,0x3e,0x02,0x02
    ,0x00,0x00,0x00,0x3e,0x22,0x02,0x22,0x3e,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x08,0x08,0x08,0x08,0x00,0x00
    ,0x00,0x00,0x00,0x22,0x22,0x22,0x22,0x3c,0x20,0x1e
    ,0x00,0x00,0x00,0x2a,0x2a,0x1c,0x2a,0x2a,0x00,0x00
    ,0x00,0x00,0x00,0x1e,0x12,0x3e,0x22,0x3e,0x00,0x00
    ,0x00,0x00,0x00,0x02,0x02,0x3e,0x22,0x3e,0x00,0x00
    ,0x00,0x00,0x00,0x22,0x02,0x3e,0x22,0x3e,0x00,0x00
    ,0x00,0x00,0x00,0x3e,0x22,0x18,0x22,0x3e,0x00,0x00
    ,0x00,0x00,0x00,0x2a,0x2a,0x2a,0x2a,0x3e,0x00,0x00
    ,0x00,0x00,0x00,0x1e,0x20,0x3c,0x20,0x1e,0x00,0x00
    ,0x00,0x00,0x00,0x2a,0x2a,0x2a,0x2a,0x7e,0x40,0x00
    ,0x00,0x00,0x00,0x22,0x22,0x3c,0x20,0x20,0x00,0x00
    ,0x00,0x00,0x00,0x07,0x05,0x3c,0x24,0x3c,0x00,0x00
    ,0x00,0x3a,0x2a,0x2a,0x2e,0x2a,0x2a,0x3a,0x00,0x00
    ,0x00,0x3c,0x22,0x22,0x22,0x3e,0x22,0x22,0x00,0x00
    ,0x00,0x3e,0x02,0x02,0x3e,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x22,0x22,0x22,0x22,0x22,0x22,0x7e,0x40,0x00
    ,0x00,0x38,0x24,0x24,0x24,0x24,0x24,0x7e,0x42,0x00
    ,0x00,0x3e,0x02,0x02,0x1e,0x02,0x02,0x3e,0x00,0x00
    ,0x00,0x3e,0x2a,0x2a,0x2a,0x2a,0x2a,0x3e,0x08,0x00
    ,0x00,0x3e,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00
    ,0x00,0x22,0x22,0x22,0x1c,0x22,0x22,0x22,0x00,0x00
    ,0x00,0x22,0x22,0x32,0x2a,0x26,0x22,0x22,0x00,0x00
    ,0x08,0x2a,0x22,0x32,0x2a,0x26,0x22,0x22,0x00,0x00
    ,0x00,0x22,0x12,0x0a,0x06,0x0a,0x12,0x22,0x00,0x00
    ,0x00,0x20,0x30,0x28,0x24,0x22,0x22,0x22,0x00,0x00
    ,0x00,0x28,0x3c,0x2a,0x2a,0x2a,0x2a,0x2a,0x00,0x00
    ,0x00,0x22,0x22,0x22,0x3e,0x22,0x22,0x22,0x00,0x00
    ,0x00,0x3e,0x22,0x22,0x22,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x3e,0x22,0x22,0x22,0x22,0x22,0x22,0x00,0x00
    ,0x00,0x3e,0x22,0x22,0x3e,0x24,0x22,0x22,0x00,0x00
    ,0x00,0x3e,0x22,0x22,0x3e,0x02,0x02,0x02,0x00,0x00
    ,0x00,0x3e,0x22,0x02,0x02,0x02,0x22,0x3e,0x00,0x00
    ,0x00,0x3e,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00
    ,0x00,0x22,0x22,0x22,0x3c,0x20,0x20,0x1e,0x00,0x00
    ,0x00,0x2a,0x2a,0x2a,0x1c,0x2a,0x2a,0x2a,0x00,0x00
    ,0x00,0x1e,0x12,0x12,0x3e,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x02,0x02,0x02,0x3e,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x22,0x22,0x02,0x3e,0x22,0x22,0x3e,0x00,0x00
    ,0x00,0x3e,0x22,0x20,0x18,0x20,0x22,0x3e,0x00,0x00
    ,0x00,0x22,0x2a,0x2a,0x2a,0x2a,0x2a,0x3e,0x00,0x00
    ,0x00,0x1e,0x20,0x20,0x3c,0x20,0x20,0x1e,0x00,0x00
    ,0x00,0x22,0x2a,0x2a,0x2a,0x2a,0x2a,0x7e,0x40,0x00
    ,0x00,0x22,0x22,0x22,0x3c,0x20,0x20,0x20,0x00,0x00
    ,0x00,0x07,0x05,0x04,0x3c,0x24,0x24,0x3c,0x00,0x00
}




--------------------
Живы будем - Не помрем !
Пользователь в офлайнеКарточка пользователяОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения

Ответить в эту темуОткрыть новую тему
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 



Текстовая версия Сейчас: 28.5.2022, 23:55