Skip to content

Python script to convert image to byte array, of color depth = 4, and bit depth = 2

Notifications You must be signed in to change notification settings

eppisai/IMAGE_TO_ARRAY

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SVG Image to Array Conversion(2 bit, 4 colors)


Python script to convert svg image to byte array, of color depth = 4, and bit depth = 2

Some examples to run the script

To convert particular Svg image :

python script.py -i checkboxfalse_icon.svg -ih 34 -iw 34

The above command converts the image named checkboxfalse_icon.svg to c header of bit depth 2,and dimensions of 34x34 (iw and ih have default value of 24, and are not required)

Output header file


#define CHECKBOXFALSE_ICON_H

#include "../../UI/Widgets/Icon2bit.h"

const Icon2bit checkboxfalse_icon = {34, 34, ImageDataFormat::Indexed2Bit, {RGB565(255,255,255), RGB565(128,128,128), RGB565(64,64,64), RGB565(0,0,0)}, (const uint8_t[]){0xf9, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xae, 0xaa, 0xaa, 0xaa, 0xaa, 0xba, 0x1b, 0x55, 0x55, 0x55, 0x55, 0xe4, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xb, 0x0, 0x0, 0x0, 0x0, 0xe0, 0x1b, 0x55, 0x55, 0x55, 0x55, 0xe4, 0xae, 0xaa, 0xaa, 0xaa, 0xaa, 0xba, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x6f}};

#endif // CHECKBOXFALSE_ICON_H

To convert all the Svg images:

python script.py -i all

The above command converts all the images (ending with _icon.svg) to c header of bit depth 2,and dimensions of 24x24

License: MIT Awesome

Screenshot_20210319_225604

About

Python script to convert image to byte array, of color depth = 4, and bit depth = 2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published