Commit 28eb09ee authored by Aaron Muir Hamilton's avatar Aaron Muir Hamilton Committed by Olaf Meeuwissen

Swap bytes in 16-bit PNGs, because PNG is big-endian.

parent 5fa4be5a
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment