将图像转换为16进制文件

xxd命令在Linux中用于将二进制文件转换为16进制表示,这对于将图像数据集成到C程序中非常有用。通过xxd-ilogo.bmplogo.h,可以将logo.bmp文件转换为C头文件,包含一个16进制表示的数组。此外,xxd还支持其他选项,如调整每行显示的十六进制数字数量、选择小端或大端字节序等,以及将十六进制数据转换回原始二进制格式。

在做图像处理时,有时需要将一张已有的图像写入到程序中。这时linux命令xxd可以完成这个需求。

注: win10可使用ubuntu子系统来使用linux命令,非常方便

xxd -i logo.bmp logo.h
此命令将logo.bmp文件的16进制数据存储为c数组

xxd命令详细说明:

Usage:
       xxd [options] [infile [outfile]]
    or
       xxd -r [-s [-]offset] [-c cols] [-ps] [infile [outfile]]
Options:
    -a          toggle autoskip: A single '*' replaces nul-lines. Default off.
    -b          binary digit dump (incompatible with -ps,-i,-r). Default hex.
    -c cols     format <cols> octets per line. Default 16 (-i: 12, -ps: 30).
    -E          show characters in EBCDIC. Default ASCII.
    -e          little-endian dump (incompatible with -ps,-i,-r).
    -g          number of octets per group in normal output. Default 2 (-e: 4).
    -h          print this summary.
    -i          output in C include file style.
    -l len      stop after <len> octets.
    -o off      add <off> to the displayed file position.
    -ps         ou
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值