🔍

首页Home › 图片工具Image Tools

🔢 位图转十六进制(BMP 像素 HEX 颜色 / C 数组)Convert Bitmap to Hex

把位图(BMP)的像素导出为十六进制:每行一排像素的 #RRGGBB 颜色网格、不带 # 的 RRGGBB、C 语言数组(0xRRGGBB,可直接用于单片机和 LED 点阵程序),或 BMP 文件里按 B-G-R 顺序存放的原始像素字节(含每行补齐的填充字节)。同时显示 BMP 文件头信息:DIB 头类型、尺寸、位深、压缩方式、行顺序和像素数据偏移。可包含透明度、选择大小写,并可先缩小到指定宽度。也支持 PNG、JPG 等图片,全部在浏览器本地完成。Export the pixels of a bitmap (BMP) as hexadecimal: a grid of #RRGGBB colours with one row of pixels per line, plain RRGGBB, a C array (0xRRGGBB, ready for microcontroller and LED-matrix code), or the raw pixel bytes exactly as the BMP file stores them in B-G-R order, row padding included. The BMP header is shown too: DIB header type, size, bit depth, compression, row order and pixel-data offset. Alpha can be included, upper or lower case chosen, and the image scaled down to a width first. PNG, JPG and other images work too; everything runs in your browser.

点击选择或拖放 BMP 位图(也支持 PNG、JPG 等图片)Click or drop a BMP bitmap here (PNG, JPG and other images work too)

使用说明与常见问题How-to & FAQ

「位图转十六进制(BMP 像素 HEX 颜色 / C 数组)」是什么?What is the Convert Bitmap to Hex tool?

把位图(BMP)的像素导出为十六进制:每行一排像素的 #RRGGBB 颜色网格、不带 # 的 RRGGBB、C 语言数组(0xRRGGBB,可直接用于单片机和 LED 点阵程序),或 BMP 文件里按 B-G-R 顺序存放的原始像素字节(含每行补齐的填充字节)。同时显示 BMP 文件头信息:DIB 头类型、尺寸、位深、压缩方式、行顺序和像素数据偏移。可包含透明度、选择大小写,并可先缩小到指定宽度。也支持 PNG、JPG 等图片,全部在浏览器本地完成。Export the pixels of a bitmap (BMP) as hexadecimal: a grid of #RRGGBB colours with one row of pixels per line, plain RRGGBB, a C array (0xRRGGBB, ready for microcontroller and LED-matrix code), or the raw pixel bytes exactly as the BMP file stores them in B-G-R order, row padding included. The BMP header is shown too: DIB header type, size, bit depth, compression, row order and pixel-data offset. Alpha can be included, upper or lower case chosen, and the image scaled down to a width first. PNG, JPG and other images work too; everything runs in your browser.

如何使用「位图转十六进制(BMP 像素 HEX 颜色 / C 数组)」?How do I use the Convert Bitmap to Hex tool?

在「位图转十六进制(BMP 像素 HEX 颜色 / C 数组)」中,选择或拖入文件,按需设置「输出格式」、「缩小到宽度(可选)」等选项,然后点击「复制」、「下载 TXT」按钮即可。In the Convert Bitmap to Hex: Choose or drop your files, set "Output", "Scale to width (optional)", then click "Copy", "Download TXT".

为什么颜色网格的第一行和 BMP 原始字节的第一行不一样?Why does the first row of the grid differ from the first row of raw bytes?

颜色网格按图片从上到下排列;而 BMP 文件默认“自下而上”存储,文件里的第一行像素其实是图片最下面一行,每个像素的字节顺序也是 B、G、R(蓝绿红)。“BMP 原始像素字节”按文件里真实的顺序输出,并标出每行的偏移和图片行号,方便对照十六进制编辑器或排查自己写的 BMP 读写代码。The colour grid runs from the top of the image to the bottom. BMP files are stored bottom-up by default, so the first row of pixels in the file is the bottom row of the picture, and each pixel's bytes are in B, G, R order. Raw BMP pixel bytes shows the data exactly as it sits in the file, with each row's offset and image row number — handy alongside a hex editor or when debugging your own BMP code.

什么是行填充字节?What are the row padding bytes?

BMP 规定每一行像素数据的长度必须是 4 字节的倍数。例如 24 位、宽 2 像素的图片每行有 6 个字节,所以末尾要补 2 个 0 凑成 8 字节。颜色网格和 C 数组里不包含填充,只有“BMP 原始像素字节”会显示它们。BMP requires every row of pixel data to be a multiple of 4 bytes long. A 24-bit image 2 pixels wide has 6 bytes per row, so 2 zero bytes are added to make 8. The colour grid and C array leave the padding out; only Raw BMP pixel bytes shows it.

C 数组怎么用?像素太多怎么办?How do I use the C array? What if there are too many pixels?

C 数组输出为 const uint32_t image[高][宽],每个元素是 0xRRGGBB(勾选“包含透明度”时是 0xAARRGGBB),可以直接复制到 Arduino、STM32 或 LED 点阵程序里,按需要再换算成 RGB565 等格式。超过 25 万像素时文本会非常大,请先填写“缩小到宽度”。The C array is const uint32_t image[height][width] with each element as 0xRRGGBB (0xAARRGGBB with Include alpha), ready to paste into Arduino, STM32 or LED-matrix code and convert further (e.g. to RGB565) if needed. Above 250,000 pixels the text gets very large, so fill in Scale to width first.

图片会被上传到服务器吗?Are my images uploaded?

不会。「位图转十六进制(BMP 像素 HEX 颜色 / C 数组)」使用浏览器 Canvas 在本地处理图片,处理后的文件直接从你的浏览器下载。No. The Convert Bitmap to Hex processes images locally with the browser Canvas API and the result downloads straight from your browser.

「位图转十六进制(BMP 像素 HEX 颜色 / C 数组)」免费吗?需要注册吗?Is the Convert Bitmap to Hex free? Do I need an account?

「位图转十六进制(BMP 像素 HEX 颜色 / C 数组)」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The Convert Bitmap to Hex is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.

相关工具Related tools

🔠 十六进制转位图(HEX / C 数组 → BMP)Convert Hex to Bitmap🧮 查看图片字节(十六进制 Hex 查看器)Print Image Bytes (Hex Viewer)🔣 位图转 RGB 数值(BMP 像素颜色值导出)Convert Bitmap to RGB Values🎞️ 动画转位图精灵图(GIF 拆帧拼成 Sprite Sheet)Convert Animation to Bitmap Sprites🔄 RGB 位图转 BGR(交换红蓝通道)Convert RGB Bitmap to BGR Bitmap✂️ 位图裁剪(按像素或百分比裁剪 BMP)Crop a Bitmap↔️ 位图水平翻转(左右镜像 BMP)Flip a Bitmap Horizontally↕️ 位图垂直翻转(上下颠倒 BMP)Flip a Bitmap Vertically🌗 位图反色(BMP 负片效果)Invert Bitmap Colours🎚️ 位图减色(减少 BMP 颜色数 / 索引色)Reduce Bitmap Colours🔲 去除位图边框(自动裁掉 BMP 四周的纯色边)Remove a Bitmap Border📐 位图缩放(调整 BMP 尺寸)Resize a Bitmap

← 全部工具All tools