Ejemplo n.º 1
0
        public int Feed(IBytesConsumer consumer, int maxbytes)
        {
            int n = 0;

            if (pendinglen == 0)
            {
                RefillBuffer();
            }
            int tofeed = maxbytes > 0 && maxbytes < pendinglen ? maxbytes : pendinglen;

            if (tofeed > 0)
            {
                n = consumer.Consume(buf, offset, tofeed);
                if (n > 0)
                {
                    offset     += n;
                    pendinglen -= n;
                }
            }
            if (n < 1 && failIfNoFeed)
            {
                throw new PngjInputException("failed feed bytes");
            }
            return(n);
        }