예제 #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");
            }

            var imlines = new ImageLines(ImgInfo, ImageLine.ESampleType.BYTE, unpackedMode, rowOffset, nRows, rowStep);

            if (!Interlaced)
            {
                for (var j = 0; j < ImgInfo.Rows; j++)
                {
                    var bytesread = ReadRowRaw(j); // read and perhaps discards
                    var mrow      = imlines.ImageRowToMatrixRowStrict(j);
                    if (mrow >= 0)
                    {
                        DecodeLastReadRowToByte(imlines.ScanlinesB[mrow], bytesread);
                    }
                }
            }
            else
            { // and now, for something completely different (interlaced)
                var buf = new byte[unpackedMode ? ImgInfo.SamplesPerRow : ImgInfo.SamplesPerRowPacked];
                for (var p = 1; p <= 7; p++)
                {
                    deinterlacer.SetPass(p);
                    for (var i = 0; i < deinterlacer.GetRows(); i++)
                    {
                        var bytesread = ReadRowRaw(i);
                        var j         = deinterlacer.GetCurrRowReal();
                        var mrow      = imlines.ImageRowToMatrixRowStrict(j);
                        if (mrow >= 0)
                        {
                            DecodeLastReadRowToByte(buf, bytesread);
                            deinterlacer.DeinterlaceByte(buf, imlines.ScanlinesB[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 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);
        }
예제 #3
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);
        }
예제 #4
0
파일: PngReader.cs 프로젝트: Daramkun/Misty
 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 );
             int mrow = imlines.ImageRowToMatrixRowStrict ( j );
             if ( mrow >= 0 )
                 decodeLastReadRowToInt ( imlines.Scanlines [ mrow ], bytesread );
         }
     }
     else
     {
         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;
 }
예제 #5
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;
 }