public static int[] Unpack(ImageInfo imgInfo, int[] src, int[] dst, bool scale) { if (imgInfo is null) { throw new ArgumentNullException(nameof(imgInfo)); } if (src is null) { throw new ArgumentNullException(nameof(src)); } var len1 = imgInfo.SamplesPerRow; var len0 = imgInfo.SamplesPerRowPacked; if (dst is null || dst.Length < len1) { dst = new int[len1]; } if (imgInfo.Packed) { ImageLine.UnpackInplaceInt(imgInfo, src, dst, scale); } else { Array.Copy(src, 0, dst, 0, len0); } return(dst); }
private void DecodeLastReadRowToInt(int[] buffer, int bytesRead) { // see http://www.libpng.org/pub/png/spec/1.2/PNG-DataRep.html if (ImgInfo.BitDepth <= 8) { for (int i = 0, j = 1; i < bytesRead; i++) { buffer[i] = (rowb[j++]); } } else { // 16 bitspc for (int i = 0, j = 1; j < bytesRead; i++) { buffer[i] = (rowb[j++] << 8) + rowb[j++]; } } if (ImgInfo.Packed && unpackedMode) { ImageLine.UnpackInplaceInt(ImgInfo, buffer, buffer, false); } }