简体   繁体   中英

How to read image data from .cr2 in C++?

How to read image data from .cr2 (raw image format by Canon) in C++?

The only one operation I need to perform is to read pixel data of .cr2 file directly if it is possible, otherwise I would like to convert it to any loss-less image and read its pixels' data.

Any suggestions?

I would go with ImageMagick too. You don't have to convert all your files up front, you can do them one at a time as you need them.

In your program, rather than opening the CR2 file, just open a pipe ( popen() call) that is executing an ImageMagick command like

convert file.cr2 ppm:-

then you can read the extremely simple PPM format which is described here - basically just a line of ASCII text that tells you the file type, then another line of ASCII text that tells you the image dimensions, followed by a max value and then the data in binary.

Later on you can actually use the ImageMagick library and API if you need to.

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