[sane-devel] Converting Raw Image Data to PNG

Andy Bennett andyjpb at ashurst.eu.org
Mon Jan 13 12:51:57 GMT 2020


>> Perhaps just raw raster pixel data? Although the ordering of 
>> the bytes and channels might take some figuring.

> I was able to get 
> the raw scan data to display, but not properly. It seems to be 
> separating the images into three sections, seemingly RGB.

The format of PNM (with a colour depth of 255) is a byte per pixel per 
colour component in the order red then green then blue.

So I guess you'd have to buffer each channel as it comes in from the 
scanner and then interleave them after each page?

This page shows you some examples http://paulbourke.net/dataformats/ppm/
The examples are in P3 rather than P6 format which just means the pixel 
component data is encoded as ASCII numbers rather than binary bytes.

See "PPM example 4".

> The 
> sideways slant of the image is also a bit off as I couldn't 
> specify the width with a double.

How are you processing the image data? Can you share a code snippet?

Best wishes,

andyjpb at ashurst.eu.org

More information about the sane-devel mailing list