The example below contains no error processing for the sake of brevity.
#include "libraw/libraw.h"
int process_image(char *file)
{
        // Let us create an image processor
        LibRaw iProcessor;
        // Open the file and read the metadata
        iProcessor.open_file(file);
        // The metadata are accessible through data fields of the class
        printf("Image size: %d x %d\n",iProcessor.imgdata.sizes.width,iProcessor.imgdata.sizes.height);
        // Let us unpack the image
        iProcessor.unpack();
        // Convert from imgdata.rawdata to imgdata.image:
        iProcessor.raw2image();
        // And let us print its dump; the data are accessible through data fields of the class
        for(i = 0;i lt; iProcessor.imgdata.sizes.iwidth *  iProcessor.imgdata.sizes.iheight; i++)
           printf("i=%d R=%d G=%d B=%d G2=%d\n",
                        i,
                        iProcessor.imgdata.image[i][0],
                        iProcessor.imgdata.image[i][1],
                        iProcessor.imgdata.image[i][2],
                        iProcessor.imgdata.image[i][3]
                );
        // Finally, let us free the image processor for work with the next image
        iProcessor.recycle();
}
    [back to Index]