Pavel Ryzhov
Pavel Ryzhov

Reputation: 5142

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?

Upvotes: 1

Views: 1512

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207365

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.

Upvotes: 1

Related Questions