in plot-api/src/commonMain/kotlin/org/jetbrains/letsPlot/util/pngj/PngReader.kt [299:330]
fun readRow(nrow: Int): IImageLine {
if (chunkseq!!.firstChunksNotYetRead()) readFirstChunks()
return if (!isInterlaced) {
if (imlinesSet == null) imlinesSet = createLineSet(true, -1, 0, 1)
val line: IImageLine = imlinesSet!!.getImageLine(nrow)
if (nrow == rowNum) return line // already read??
else if (nrow < rowNum) throw PngjInputException("rows must be read in increasing order: $nrow")
while (rowNum < nrow) {
while (!chunkseq.idatSet!!.isRowReady) {
if (streamFeeder!!.feed(chunkseq) < 1) throw PngjInputException("premature ending")
}
rowNum++
chunkseq.idatSet!!.updateCrcs(idatCrca, idatCrcb)
if (rowNum == nrow) {
line.readFromPngRaw(
chunkseq.idatSet!!.unfilteredRow!!, curImgInfo.bytesPerRow + 1, 0,
1
)
line.endReadFromPngRaw()
}
chunkseq.idatSet!!.advanceToNextRow()
}
line
} else { // and now, for something completely different (interlaced!)
if (imlinesSet == null) {
imlinesSet = createLineSet(false, curImgInfo.rows, 0, 1)
loadAllInterlaced(curImgInfo.rows, 0, 1)
}
rowNum = nrow
imlinesSet!!.getImageLine(nrow)
}
}