Create a gist now

Instantly share code, notes, and snippets.

@koutoftimer /run.cpp Secret
Created Mar 13, 2015

What would you like to do?
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