Example #1
0
        public Fctl(Ihdr ihdr, UInt32 frame, UInt32 x, UInt32 y, UInt32 width, UInt32 height, Rational delay, ApngDisposeOperation disposeOp, ApngBlendOperation blendOp)
            : base(ChunkType.fcTL)
        {
            #region sanity
            if(width == 0)
                throw new ArgumentOutOfRangeException("width", "width must be > 0");
            if(height == 0)
                throw new ArgumentOutOfRangeException("height", "height must be > 0");

            if(x + width > ihdr.Width)
                throw new ArgumentException("x + width(" + (x + (UInt64)width) + ") must be smaller than canvas width: " + ihdr.Width);
            if(y + height > ihdr.Height)
                throw new ArgumentException("y + height(" + (y + (UInt64)height) + ") must be smaller than canvas height: " + ihdr.Height);
            #endregion

            _frame = frame;
            _x = x;
            _y = y;
            _width = width;
            _height = height;
            _delay = delay;
            _disposeOp = disposeOp;
            _blendOp = blendOp;

            _memStream.Write(NoHelper.GetBytes(_frame), 0, 4);
            _memStream.Write(NoHelper.GetBytes(_width), 0, 4);
            _memStream.Write(NoHelper.GetBytes(_height), 0, 4);
            _memStream.Write(NoHelper.GetBytes(_x), 0, 4);
            _memStream.Write(NoHelper.GetBytes(_y), 0, 4);
            _memStream.Write(NoHelper.GetBytes(delay.Numerator), 0, 2);
            _memStream.Write(NoHelper.GetBytes(delay.Denominator), 0, 2);
            _memStream.WriteByte((Byte)disposeOp);
            _memStream.WriteByte((Byte)blendOp);
        }
Example #2
0
        //read http://stackoverflow.com/questions/6216094/implementing-the-apng-render-function
        public Tuple<Fctl, Fdat> EncodeFrame(Ihdr ihdr, InternalImage img, uint sequenceNumber, InternalImage lastImage, Rational delay)
        {
            //Rectangle bb = CalculateDifferenceBoundingBox(img, lastImage);
            //float approxns = ApproximateCompressionSize(img, lastImage, bb, ApngDisposeOperation.None, ApngBlendOperation.Source);
            //float approxns = ApproximateCompressionSize(img, lastImage, bb, ApngDisposeOperation., ApngBlendOperation.Source);

            return new Tuple<Fctl, Fdat>(new Fctl(ihdr, sequenceNumber, 0, 0, img.Ihdr.Width, img.Ihdr.Height, delay, ApngDisposeOperation.None, ApngBlendOperation.Source), new Fdat(sequenceNumber+1, Encode(img, lastImage), true));
        }
Example #3
0
 public Tuple<Fctl, Fdat> EncodeFrame(Ihdr ihdr, InternalImage img, uint sequenceNumber, InternalImage lastImage, Rational delay)
 {
     return new Tuple<Fctl, Fdat>(new Fctl(ihdr, sequenceNumber, 0, 0, img.Ihdr.Width, img.Ihdr.Height, delay, ApngDisposeOperation.None, ApngBlendOperation.Source), new Fdat(sequenceNumber+1, Encode(img, lastImage), true));
 }