[sane-devel] [PATCH v3 1/2] add PNG format to scanimage

Matteo Croce matteo at openwrt.org
Fri Sep 18 09:44:30 UTC 2015


2015-09-17 15:02 GMT+02:00 Olaf Meeuwissen <paddy-hack at member.fsf.org>:
> Hi Matteo,
>
> Sorry for not replying earlier.
>
> I've reviewed your patch in more detail and things look okay.  There do
> not seem to be any leaks (only scanned a single image) as the valgrind
> output is the same as for PNM output.
>
> There is one showstopper though.  The 1-bit scans come out inverted.
> I used the pnm backend to read in a PBM file and output that to PNG.
> The black and white are the other way around in the output.  Oops.
>
> Please see the bottom of
>
>   http://sane.alioth.debian.org/html/doc008.html#s3.2
>
> for why.  My guess as to this odd behaviour is to align the pixel values
> to the way PNM defines them.
>
> Can you fix this?

The issue is different, from the sane documentation it seems that when
doing 1 bit scan the colors are inverted,
1 is black and 0 is white (maybe for TIFF compatibility)?:

"In frames of type SANE_FRAME_GRAY, when the bit depth is 1 there are
only two sample values possible, 1 represents minimum intensity
(black) and 0 represents maximum intensity (white). For all other bit
depth and frame type combinations, a sample value of 0 represents
minimum intensity and larger values represent increasing intensity."

I've inverted the bit value when the bit depth is 1, now it seems to
work fine, patches will follow soon :)

-- 
Matteo Croce
OpenWrt Developer
  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 CHAOS CALMER
 -----------------------------------------------------
  * 1 1/2 oz Gin            Shake with a glassful
  * 1/4 oz Triple Sec       of broken ice and pour
  * 3/4 oz Lime Juice       unstrained into a goblet.
  * 1 1/2 oz Orange Juice
  * 1 tsp. Grenadine Syrup
 -----------------------------------------------------



More information about the sane-devel mailing list