GetOffset() 공개 메소드

public GetOffset ( ) : long
리턴 long
예제 #1
0
        private int ReadRowRaw(int nrow)
        {
            //
            if (nrow == 0 && FirstChunksNotYetRead())
            {
                ReadFirstChunks();
            }
            if (nrow == 0 && interlaced)
            {
                Array.Clear(rowb, 0, rowb.Length); // new subimage: reset filters: this is enough, see the swap that happens lines
            }
            // below
            int bytesRead = ImgInfo.BytesPerRow; // NOT including the filter byte

            if (interlaced)
            {
                if (nrow < 0 || nrow > deinterlacer.getRows() || (nrow != 0 && nrow != deinterlacer.getCurrRowSubimg() + 1))
                {
                    throw new PngjInputException("invalid row in interlaced mode: " + nrow);
                }
                deinterlacer.setRow(nrow);
                bytesRead = (ImgInfo.BitspPixel * deinterlacer.getPixelsToRead() + 7) / 8;
                if (bytesRead < 1)
                {
                    throw new PngjExceptionInternal("wtf??");
                }
            }
            else     // check for non interlaced
            {
                if (nrow < 0 || nrow >= ImgInfo.Rows || nrow != rowNum + 1)
                {
                    throw new PngjInputException("invalid row: " + nrow);
                }
            }
            rowNum = nrow;
            // swap buffers
            byte[] tmp = rowb;
            rowb     = rowbprev;
            rowbprev = tmp;
            // loads in rowbfilter "raw" bytes, with filter
            PngHelperInternal.ReadBytes(idatIstream, rowbfilter, 0, bytesRead + 1);
            offset = iIdatCstream.GetOffset();
            if (offset < 0)
            {
                throw new PngjExceptionInternal("bad offset ??" + offset);
            }
            if (MaxTotalBytesRead > 0 && offset >= MaxTotalBytesRead)
            {
                throw new PngjInputException("Reading IDAT: Maximum total bytes to read exceeeded: " + MaxTotalBytesRead
                                             + " offset:" + offset);
            }
            rowb[0] = 0;
            UnfilterRow(bytesRead);
            rowb[0] = rowbfilter[0];
            if ((rowNum == ImgInfo.Rows - 1 && !interlaced) || (interlaced && deinterlacer.isAtLastRow()))
            {
                ReadLastAndClose();
            }
            return(bytesRead);
        }
예제 #2
0
        public int ReadRowRaw(int nrow)
        {
            if (nrow == 0 && FirstChunksNotYetRead())
            {
                ReadFirstChunks();
            }
            if (nrow == 0 && interlaced)
            {
                Array.Clear(rowb, 0, rowb.Length);
            }
            int num = ImgInfo.BytesPerRow;

            if (interlaced)
            {
                if (nrow < 0 || nrow > deinterlacer.getRows() || (nrow != 0 && nrow != deinterlacer.getCurrRowSubimg() + 1))
                {
                    throw new PngjInputException("invalid row in interlaced mode: " + nrow.ToString());
                }
                deinterlacer.setRow(nrow);
                num = (ImgInfo.BitspPixel * deinterlacer.getPixelsToRead() + 7) / 8;
                if (num < 1)
                {
                    throw new PngjExceptionInternal("wtf??");
                }
            }
            else if (nrow < 0 || nrow >= ImgInfo.Rows || nrow != rowNum + 1)
            {
                throw new PngjInputException("invalid row: " + nrow.ToString());
            }
            rowNum = nrow;
            byte[] array = rowb;
            rowb     = rowbprev;
            rowbprev = array;
            PngHelperInternal.ReadBytes(idatIstream, rowbfilter, 0, num + 1);
            offset = iIdatCstream.GetOffset();
            if (offset < 0)
            {
                throw new PngjExceptionInternal("bad offset ??" + offset.ToString());
            }
            if (MaxTotalBytesRead > 0 && offset >= MaxTotalBytesRead)
            {
                throw new PngjInputException("Reading IDAT: Maximum total bytes to read exceeeded: " + MaxTotalBytesRead.ToString() + " offset:" + offset.ToString());
            }
            rowb[0] = 0;
            UnfilterRow(num);
            rowb[0] = rowbfilter[0];
            if ((rowNum == ImgInfo.Rows - 1 && !interlaced) || (interlaced && deinterlacer.isAtLastRow()))
            {
                ReadLastAndClose();
            }
            return(num);
        }