Add new comment

reading .raw with LibRaw iProcessor example

Hello everyone,
I am trying to read a raw image with libraw using the example in the API page " https://www.libraw.org/docs/API-overview.html"
I wrote the following code and get a -2 file reading error.
I was able to read the same raw image with Python (fromfile) specifying bit ordering to 'big'. What should I do to read to do this with libraw in C++?

#include <iostream>
#include "libraw/libraw.h"
#include "libraw/libraw.h"
int main(int argc, char **argv)
{
	LibRaw iProcessor;
 
	// Open the file and read the metadata
	char *fname = (char *)"/home/santana/myraw.raw";
 
	int isOK = iProcessor.open_file(fname);
	std::cout << " is ok ? " << isOK << std::endl;
	printf("Image size: %d x %d\n", iProcessor.imgdata.sizes.width,  iProcessor.imgdata.sizes.height);
	iProcessor.unpack();
	// Convert from imgdata.rawdata to imgdata.image:
	iProcessor.raw2image();
	for (int i = 0; i < 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();
 
	return EXIT_SUCCESS;
}

output :

is ok ? -2
Image size: 0 x 0

Forums: