[sane-devel] sane-canon: Endian inverted data when scanning 48bbp raw mode pnm

Jean-Michel Vourgère contact_mlsane at nirgal.com
Tue Dec 27 15:47:21 UTC 2005


On Tuesday 27 December 2005 14:32, Henning Meier-Geinitz wrote:
> > Using imagemagick on the raw data give images with noise. Switching
> > bytes before using imagemagick' convert works ok.
> > The noise also appears in preview window when mode is raw, so the bug
> > is probably in sane and not imagemagick.
> Maybe the author of the backend uses a big endian machine :-)

It's probable :

I had a look at the source and the data is vonluntarily byte swicthed during output, due to little endian detection:
#if !defined(WORDS_BIGENDIAN) line 1334 of sane-backends-1.0.17/frontend/scanimage.c

I tested: That code is run.

However, the data is allready byte-switched in the backend (canon-sane.c function read_fs2710 line 1790) with that comment:
  /* We must receive 2 bytes per pixel and colour. In raw mode we
     must swap the bytes (for compatibility with xsane) and pass
     them both. (...) */
That particuliar inversion is allways performed, no matter the platform "endianness".

Unless I missed something, I guess the byte switch in scanimage.c was only needed for some other backends. :(

But then wouldn't it make sense to byte-switch the data in the backends when needed rather than to do it twice when not needed?

I was unable to test xsane.

I'm done with old chimical films anyways (I definitly should have kept one for testing!), I hope that message and my previous workaround will help others.

> To make sure that it's not a problem with imagemagic you can check if
> the test images are ok:
>  scanimage -d test --resolution 250 --mode Color --depth 16 --test-picture "Color Pattern" >image.pnm
> and compare the image with this page (last image)
> http://www.meier-geinitz.de/sane/test-backend/test-pictures.html

Test successfull. The problem is not with image magick.

Thanks for the tip Henning ! :)



More information about the sane-devel mailing list