简体   繁体   English

RGB888(24位)到PNG / JPEG图像算法

[英]RGB888 (24 bit) to PNG/JPEG image algorithm

I need to convert 24 bit RGB(888) image data to PNG or JPEG image (whichever possible). 我需要将24位RGB(888)图像数据转换为PNG或JPEG图像(尽可能)。 Need simpler approach to do this same like converting RGB888 to BMP without any compression. 需要更简单的方法来做到这一点,比如将RGB888转换为BMP而不进行任何压缩。 Would be great if it is something like adding PNG/JPEG headers to the RGB data with/without little modification. 如果它有点像将数据添加到RGB数据,有/没有很少的修改,那就太棒了。 Ready to provide more details on request.. 随时准备提供更多详细信息..

Thanks in advance.. 提前致谢..

Language/Platform : C/Linux 语言/平台:C / Linux

使用miniz - aka单个C源文件Deflate / Inflate压缩库与zlib兼容的API,ZIP存档读/写,PNG写入。

If you just need an image format then the easiest is probably ppm (or pgm for greyscale) 如果您只需要图像格式,那么最简单的可能是ppm (或者是灰度的pgm)

You just need to add a small ascii header to the uncompressed binary data and most image apps will read it. 您只需要在未压缩的二进制数据中添加一个小的ascii标头,大多数图像应用程序都会读取它。

P6   <-- magic value for binary data
# a comment if you want
640 480    <-- width x height
255      <-- max pixel value
.... binary data here .......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM