Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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 imageLines = new ImageLines(ImgInfo, ImageLine.ESampleType.BYTE, 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)
                    {
                        decodeLastReadRowToByte(imageLines.ScanlinesB[num], bytesRead);
                    }
                }
            }
            else
            {
                byte[] array = new byte[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)
                        {
                            decodeLastReadRowToByte(array, bytesRead2);
                            deinterlacer.deinterlaceByte(array, imageLines.ScanlinesB[num2], !unpackedMode);
                        }
                    }
                }
            }
            End();
            return(imageLines);
        }