in plot-api/src/commonMain/kotlin/org/jetbrains/letsPlot/util/pngj/PngReader.kt [354:388]
fun readRows(nRows: Int, rowOffset: Int, rowStep: Int): IImageLineSet<out IImageLine> {
@Suppress("NAME_SHADOWING")
var nRows = nRows
if (chunkseq!!.firstChunksNotYetRead()) readFirstChunks()
if (nRows < 0) nRows = (curImgInfo.rows - rowOffset) / rowStep
if (rowStep < 1 || rowOffset < 0 || nRows == 0 || nRows * rowStep + rowOffset > curImgInfo.rows) throw PngjInputException(
"bad args"
)
if (rowNum >= rowOffset) throw PngjInputException("readRows cannot be mixed with readRow")
imlinesSet = createLineSet(false, nRows, rowOffset, rowStep)
if (!isInterlaced) {
var m = -1 // last row already read in
while (m < nRows - 1) {
while (!chunkseq.idatSet!!.isRowReady) {
if (streamFeeder!!.feed(chunkseq) < 1) throw PngjInputException("Premature ending")
}
rowNum++
chunkseq.idatSet!!.updateCrcs(idatCrca, idatCrcb)
m = (rowNum - rowOffset) / rowStep
if (rowNum >= rowOffset && rowStep * m + rowOffset == rowNum) {
val line: IImageLine = imlinesSet!!.getImageLine(rowNum)
line.readFromPngRaw(
chunkseq.idatSet!!.unfilteredRow!!, curImgInfo.bytesPerRow + 1, 0,
1
)
line.endReadFromPngRaw()
}
chunkseq.idatSet!!.advanceToNextRow()
}
} else { // and now, for something completely different (interlaced)
loadAllInterlaced(nRows, rowOffset, rowStep)
}
chunkseq.idatSet!!.markAsDone()
return imlinesSet!!
}