[sane-devel] Converting Raw Image Data to PNG

Alexander Pevzner pzz at apevzner.com
Fri Jan 10 09:49:04 GMT 2020

Hi Daniel,

On 1/10/20 8:09 AM, daniel at pixelgrease.co wrote:
> 1. What format is that raw data likely to be? I naively expected it to 
> be png.
> 2. Does SANE have some code that handles that sort of conversion I could 
> have a look at? Looked around the internet and the SANE docs. Read some 
> things about frames, but couldn't find much else.

Raw data is likely to be just a matrix (2D array) of pixels. One byte 
per pixel in grayscale mode and 3 bytes per pixel in color mode.

In SANE world, there are drivers, called "backends" and client programs, 
called "frontend".

Backends are dynamically loaded libraries, such as sane-pixma 
(/usr/lib/sane/libsane-pixma.so.1) and so on.

Frontends are programs, line simple-scan, scanimage, xsane or even gimp.

Frontend always returns picture in raw format, even if it comes from 
device in some another format (say, PNG or JPEG). This is a 
responsibility of frontend to convert the image into something useful, 
like JPEG or PDF file.

So if you are about to write sane backend, this is not your 
responsibility to convert the image into PNG, but if image comes from 
device as PNG, this is your responsibility to unpack it.


	Wishes, Alexander Pevzner (pzz at apevzner.com)

More information about the sane-devel mailing list