我需要 static const uint8_t 形式的图标,因为我已经有一个包含许多这种形式图标的 icon.h 库。通常每行大约 70 行长
我尝试在 64x64 .png 上使用以下 ImageMagick 命令:
convert /home/XXX/TempStuff/Arrow-circle-down.png -define h:format=gray -depth 8 -size 64x64 /home/XXX/TempStuff/grey64x64.h
但结果是一个“static const unsigned char”数组,长度为 87,000 行。
如何将 .png 文件转换为“static const uint8_t”数组?
-size WxH
设置仅定义您随后使用 xc:red
或 gradient:cyan-yellow
或类似工具创建的任何画布的大小。
实际上,您可能想要更改现有图像的大小,为此您需要使用
-resize WxH
,如下所示:
convert input.jpg -resize 64x64 result.jpg
如果你想要一个头文件(又名包含)文件,请使用
xxd
,如下所示:
convert -size 8x8 xc:magenta a.rgb
xxd -i a.rgb
unsigned char a_rgb[] = {
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff ...