|
发表于 2024-1-15 14:41:43
|
显示全部楼层
本帖最后由 dukelec 于 2024-1-15 14:59 编辑
一条命令搞定(convert 命令属于 ImageMagick 开源软件):
- $ convert IN.png -type truecolor OUT.rgb
复制代码
生成 RGB 裸数据,输入图片可以是任意通用格式
rgb 裸数据转 c 语言数组头文件也是一条命令的事:
还可以顺便改改颜色、尺寸、旋转,譬如:
- $ convert IN.png -fill white -resize 50x100% -modulate 100 -modulate 100,100 -colorize 40 -geometry x684 -bordercolor none -alpha remove -rotate 90 -type truecolor OUT.rgb
复制代码
参数解释:
brightness:
-modulate xxx # default 100, recommended range: 80~130
saturation:
-modulate 100,xxx # default 100, recommended range: 90~150
density_n:
-colorize xxx # required range: 1~100, recommended: 20~50
需要 rgb565 的话,可以用 ffmpeg 命令:
- $ ffmpeg -i IN.png -pix_fmt rgb565 OUT.rgb
复制代码
或者依旧用 convert 命令,先增加参数 “-define bmp:subtype=RGB565”,转成 bmp 文件,再把 bmp 文件的最后 长 x 宽 x 2 bytes 数据取出来就行了:
https://stackoverflow.com/questi ... -without-bmp-header |
|