private void decodeLastReadRowToByte(byte[] buffer, int bytesRead)
{
// see http://www.libpng.org/pub/png/spec/1.2/PNG-DataRep.html
if (ImgInfo.BitDepth <= 8) {
Array.Copy(rowb, 1, buffer, 0, bytesRead);
} else { // 16 bitspc
for (int i = 0, j = 1; j < bytesRead; i++, j += 2)
buffer[i] = rowb[j]; // 16 bits in 1 byte: this discards the LSB!!!
}
if (ImgInfo.Packed && unpackedMode)
ImageLine.unpackInplaceByte(ImgInfo, buffer, buffer, false);
}