Skip to content

Instantly share code, notes, and snippets.

@koutoftimer
Created March 13, 2015 06:49
Show Gist options
  • Save koutoftimer/caef274d5d0041adf3ec to your computer and use it in GitHub Desktop.
Save koutoftimer/caef274d5d0041adf3ec to your computer and use it in GitHub Desktop.
open raw (panasonic rw2) files
#include <libraw/libraw.h>
#include <algorithm>
#include <fstream>
#include <iomanip>
void process_image(char *file) {
LibRaw handler;
handler.open_file(file);
handler.unpack();
std::ofstream out("out.txt");
int width = handler.imgdata.sizes.raw_width,
height = handler.imgdata.sizes.raw_height;
for (int row = 0; row < height; ++row) {
for (int col = 0; col < width; ++col) {
int channel = handler.COLOR(row, col);
out << handler.imgdata.idata.cdesc[channel]
<< std::setw(4) << std::setfill('0')
<< handler.imgdata.rawdata.raw_image[row * width + col];
}
out << "EOL";
}
out.close();
}
int main(int argc, char *argv[]) {
if (argc != 2) return 1;
process_image(argv[1]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment