Пример #1
0
        public ImageLines ReadRowsInt(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.INT, 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)
                    {
                        decodeLastReadRowToInt(imlines.Scanlines[mrow], bytesread);
                    }
                }
            }
            else     // and now, for something completely different (interlaced)
            {
                int[] buf = new int[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)
                        {
                            decodeLastReadRowToInt(buf, bytesread);
                            deinterlacer.deinterlaceInt(buf, imlines.Scanlines[mrow], !unpackedMode);
                        }
                    }
                }
            }
            End();
            return(imlines);
        }
Пример #2
0
        public ImageLines ReadRowsInt(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 imageLines = new ImageLines(ImgInfo, ImageLine.ESampleType.INT, unpackedMode, rowOffset, nRows, rowStep);

            if (!interlaced)
            {
                for (int i = 0; i < ImgInfo.Rows; i++)
                {
                    int bytesRead = ReadRowRaw(i);
                    int num       = imageLines.ImageRowToMatrixRowStrict(i);
                    if (num >= 0)
                    {
                        decodeLastReadRowToInt(imageLines.Scanlines[num], bytesRead);
                    }
                }
            }
            else
            {
                int[] array = new int[unpackedMode ? ImgInfo.SamplesPerRow : ImgInfo.SamplesPerRowPacked];
                for (int j = 1; j <= 7; j++)
                {
                    deinterlacer.setPass(j);
                    for (int k = 0; k < deinterlacer.getRows(); k++)
                    {
                        int bytesRead2  = ReadRowRaw(k);
                        int currRowReal = deinterlacer.getCurrRowReal();
                        int num2        = imageLines.ImageRowToMatrixRowStrict(currRowReal);
                        if (num2 >= 0)
                        {
                            decodeLastReadRowToInt(array, bytesRead2);
                            deinterlacer.deinterlaceInt(array, imageLines.Scanlines[num2], !unpackedMode);
                        }
                    }
                }
            }
            End();
            return(imageLines);
        }