[sane-devel] Converting Raw Image Data to PNG
paddy-hack at member.fsf.org
Tue Jan 14 12:14:27 GMT 2020
Hi Daniel, Andy, list,
Sorry, am a bit pre-occupied and busy with the upcoming 1.0.29 release
Andy Bennett writes:
>> Thank you for your responses. I was able to get something! Almost there.
>> I've attached an image of progress so far. By preapending the
>> "magic pnm code" to the top of the data file 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
>> sideways slant of the image is also a bit off as I couldn't
>> specify the width with a double.
> I think you have the dimensions slightly off, but the width (1296) seems
> As you say, the image appears slanted and when I try to convert RGBTest.pnm
> to png I get the following:
> $ pnmtopng RGBTest.pnm > RGBTest.png
> pnmtopng: EOF / read error reading a row of pixels
> It looks like there's an extra 5 pixels every 15 lines or so, except for
> every 5 set of 15.
> 15 lines fit into 20KiB, but 16 do not. I'm not sure if that's relevant at
> all. Perhaps there's some extra framing, checksum or meta data coming in
> from somewhere?
I had a quick look at the image only but it appears to be image in a
format very similar to
where every R, G and B, stands for a single pixel's RGB values. You'll
have to rearrange those in your backend. The p stands for padding bytes
and need to be skipped when preparing the image data that your backend
This kind of image data is(was?) pretty common and you should be able to
find usable code in several of the SANE Backends. I know that the epson
(and epson2?) backend is able to handle such data.
Hope this helps,
Olaf Meeuwissen, LPIC-2 FSF Associate Member since 2004-01-27
GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13 F43E B8A4 A88A F84A 2DD9
Support Free Software https://my.fsf.org/donate
Join the Free Software Foundation https://my.fsf.org/join
More information about the sane-devel