コード例 #1
0
ファイル: DelayCompositer.cs プロジェクト: jfpk/kinoveaIDS
        public Bitmap Get(int age)
        {
            if (composite == null)
            {
                throw new InvalidOperationException();
            }

            if (!allocated || image == null)
            {
                return(null);
            }

            if (composite.Subframes == null || composite.Subframes.Count == 0)
            {
                return(delayer.Get(age));
            }

            Graphics g = Graphics.FromImage(image);

            g.InterpolationMode = InterpolationMode.NearestNeighbor;

            composite.Tick();
            currentPosition++;
            if (!composite.NeedsRefresh)
            {
                return(image);
            }

            foreach (IDelaySubframe subframe in composite.Subframes)
            {
                int subframeAge = composite.GetAge(subframe);

                if (subframeAge < 0)
                {
                    continue;
                }

                Bitmap subframeImage = delayer.Get(subframeAge);
                g.DrawImage(subframeImage, subframe.Bounds);

                // Debug
                //int subframePosition = currentPosition - subframeAge;
                //string text = string.Format("frame:{0}, current:{1}.", subframePosition, currentPosition);
                //g.DrawString(text, font, Brushes.Red, subframe.Bounds.Location);
            }

            return(image);
        }
コード例 #2
0
        public Bitmap Get(int age)
        {
            if (composite == null)
            {
                throw new InvalidOperationException();
            }

            if (!allocated || image == null)
            {
                return(null);
            }

            if (composite.Subframes == null || composite.Subframes.Count == 0)
            {
                return(delayer.Get(age));
            }

            Graphics g = Graphics.FromImage(image);

            g.InterpolationMode = InterpolationMode.NearestNeighbor;

            composite.Tick();
            currentPosition++;
            if (!composite.NeedsRefresh)
            {
                return(image);
            }

            foreach (IDelaySubframe subframe in composite.Subframes)
            {
                int subframeAge = composite.GetAge(subframe);

                if (subframeAge < 0)
                {
                    continue;
                }

                Bitmap subframeImage = delayer.Get(subframeAge);
                g.DrawImage(subframeImage, subframe.Destination, subframe.Source, GraphicsUnit.Pixel);
            }

            return(image);
        }