public ImageLines ReadRowsByte(int rowOffset, int nRows, int rowStep)
{
if (nRows < 0)
nRows = (ImgInfo.Rows - rowOffset) / rowStep;
if (rowStep < 1 || rowOffset < 0 || nRows * rowStep + rowOffset > ImgInfo.Rows)
throw new PngjInputException("bad args");
ImageLines imlines = new ImageLines(ImgInfo, ImageLine.ESampleType.BYTE, unpackedMode, rowOffset, nRows, rowStep);
if (!interlaced) {
for (int j = 0; j < ImgInfo.Rows; j++) {
int bytesread = ReadRowRaw(j); // read and perhaps discards
int mrow = imlines.ImageRowToMatrixRowStrict(j);
if (mrow >= 0)
decodeLastReadRowToByte(imlines.ScanlinesB[mrow], bytesread);
}
} else { // and now, for something completely different (interlaced)
byte[] buf = new byte[unpackedMode ? ImgInfo.SamplesPerRow : ImgInfo.SamplesPerRowPacked];
for (int p = 1; p <= 7; p++) {
deinterlacer.setPass(p);
for (int i = 0; i < deinterlacer.getRows(); i++) {
int bytesread = ReadRowRaw(i);
int j = deinterlacer.getCurrRowReal();
int mrow = imlines.ImageRowToMatrixRowStrict(j);
if (mrow >= 0) {
decodeLastReadRowToByte(buf, bytesread);
deinterlacer.deinterlaceByte(buf, imlines.ScanlinesB[mrow], !unpackedMode);
}
}
}
}
End();
return imlines;
}