Example #1
0
        private void InitImages()
        {
            if (APNGFile.IsAnimated)
            {
                Bitmap current  = new Bitmap((int)APNGFile.Width, (int)APNGFile.Height);
                Bitmap previous = null;

                ImageRender.RenderNextFrame(current, Point.Empty, APNGFile.ToBitmap(0), Frame.BlendOperation.SOURCE);
                Images.Add(new Bitmap(current));

                for (int i = 1; i < APNGFile.FrameCount; i++)
                {
                    APNGLib.Frame oldFrame = APNGFile.GetFrame(i - 1);
                    Bitmap        prev     = previous == null ? null : new Bitmap(previous);
                    if (oldFrame.DisposeOp != APNGLib.Frame.DisposeOperation.PREVIOUS)
                    {
                        previous = new Bitmap(current);
                    }
                    ImageRender.DisposeBuffer(current, new Rectangle((int)oldFrame.XOffset, (int)oldFrame.YOffset, (int)oldFrame.Width, (int)oldFrame.Height), oldFrame.DisposeOp, prev);
                    APNGLib.Frame currFrame = APNGFile.GetFrame(i);
                    ImageRender.RenderNextFrame(current, new Point((int)currFrame.XOffset, (int)currFrame.YOffset), APNGFile.ToBitmap(i), currFrame.BlendOp);
                    Images.Add(new Bitmap(current));
                }
            }
            else
            {
                Images.Add(APNGFile.ToBitmap());
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        public List <data_apng> fun_取得解析後的APNG()
        {
            List <data_apng> ar_apng = new List <data_apng>();

            if (APNGFile.IsAnimated)
            {
                Bitmap current  = new Bitmap((int)APNGFile.Width, (int)APNGFile.Height);
                Bitmap previous = null;

                ImageRender.RenderNextFrame(current, System.Drawing.Point.Empty, APNGFile.ToBitmap(0), Frame.BlendOperation.SOURCE);
                fun_add(new Bitmap(current), ar_apng, APNGFile.GetFrame(0).Milliseconds);

                for (int i = 1; i < APNGFile.FrameCount; i++)
                {
                    APNGLib.Frame oldFrame = APNGFile.GetFrame(i - 1);
                    Bitmap        prev     = previous == null ? null : new Bitmap(previous);
                    if (oldFrame.DisposeOp != APNGLib.Frame.DisposeOperation.PREVIOUS)
                    {
                        previous = (current);
                    }
                    ImageRender.DisposeBuffer(current, new Rectangle((int)oldFrame.XOffset, (int)oldFrame.YOffset, (int)oldFrame.Width, (int)oldFrame.Height), oldFrame.DisposeOp, prev);
                    APNGLib.Frame currFrame = APNGFile.GetFrame(i);
                    ImageRender.RenderNextFrame(current, new System.Drawing.Point((int)currFrame.XOffset, (int)currFrame.YOffset), APNGFile.ToBitmap(i), currFrame.BlendOp);
                    fun_add(new Bitmap(current), ar_apng, APNGFile.GetFrame(i).Milliseconds);


                    if (prev != null)
                    {
                        prev.Dispose();
                        prev = null;
                    }
                }

                if (current != null)
                {
                    current.Dispose();
                    current = null;
                }
                if (previous != null)
                {
                    previous.Dispose();
                    previous = null;
                }
            }
            else    //如果不是動畫

            {
                fun_add(APNGFile.ToBitmap(), ar_apng, 60);
            }

            return(ar_apng);
        }