# 4bits_png **Repository Path**: imhzy/4bits_png ## Basic Information - **Project Name**: 4bits_png - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-21 - **Last Updated**: 2025-12-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # BIN to PNG Converter 这个程序可以将4位灰度的二进制文件直接转换为4位灰度的PNG图像。 ## 编译 确保系统安装了libpng开发库,然后运行: ```bash make ``` 在Ubuntu/Debian系统上安装libpng开发库: ```bash sudo apt-get install libpng-dev ``` ## 使用方法 ```bash ./bin_to_png <输入文件> <输出文件> <宽度> <高度> ``` 例如: ```bash ./bin_to_png pic.bin output.png 4 2 ``` ## 说明 - 输入文件应包含4位灰度数据(每个字节包含两个像素) - 程序会将数据直接转换为4位灰度PNG图像,不进行位扩展 - 使用了简化的动态哈夫曼算法概念处理数据 - 生成的PNG文件保持原始的4位色彩深度,文件更小 ## 关于PNM和PNG - PNM(Portable Any Map)是一种简单的图像格式 - PNG(Portable Network Graphics)是一种更复杂的图像格式,支持压缩和多种颜色深度 - 虽然PNG支持4位灰度,但大多数图像处理库默认使用8位 - 本程序直接生成4位灰度PNG文件,保持了原始数据的颜色深度