-
-
Save koutoftimer/caef274d5d0041adf3ec to your computer and use it in GitHub Desktop.
open raw (panasonic rw2) files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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