---
 frontend/scanimage.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/frontend/scanimage.c b/frontend/scanimage.c
index 77c2288..0925039 100644
--- a/frontend/scanimage.c
+++ b/frontend/scanimage.c
@@ -1529,6 +1529,19 @@ scan_it (FILE *ofp)
                          for(j = 0; j < parm.bytes_per_line; j++)
                            pngbuf[j] = ~pngbuf[j];
                        }
+                     /* PNG is big-endian */
+                     /* see: 
https://www.w3.org/TR/2003/REC-PNG-20031110/#7Integers-and-byte-order */
+                     if (parm.depth == 16)
+                       {
+                         int j;
+                         for (j = 0; j < parm.bytes_per_line; j += 2)
+                           {
+                             SANE_Byte LSB;
+                             LSB = pngbuf[j];
+                             pngbuf[j] = pngbuf[j + 1];
+                             pngbuf[j + 1] = LSB;
+                           }
+                       }
                      png_write_row(png_ptr, pngbuf);
                      i += parm.bytes_per_line - pngrow;
                      left -= parm.bytes_per_line - pngrow;
-- 
1.8.3.1


-- 
sane-devel mailing list: [email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [email protected]

Reply via email to