简体   繁体   中英

Read RGB triplets of JPEG files in C

to read bmp files we may use this http://msdn.microsoft.com/en-us/library/dd183376(VS.85).aspx as the header file and then get rgb triplets. How to get the rgb triplets of jpeg file, is there any such header file available. Please share the link if any.

The JPEG file format does not store the rgb triplets directly but it uses some sort of image compression. The file actually contains blocks of 64 (if I remember correctly) pixels which are attributed with a cosine pattern defining the actual colors.

You really should use a library (libjpeg, imagemagick, gd, ... eg, depending on your use case) to read and decode the files and generate the rgb triplets in memory.

According to the answer to this question on MSDN , you could use the GDI+ component, which can load not only BMP, but JPG and other image formats too. From it, you will get a memory bitmap.

Here is an example on how to do that.

Check this library: libjpeg . This library implements JPEG image encoding, decoding, and transcoding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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