private void SetConfiguration(ImageDescriptor imageDescriptor, int totalFrames, int count)
        {
            // Frozen mosaic.
            // Note that images are reverted so that motion unwind from left to right and top to bottom.
            // The first image of the index is the oldest one.

            subframes.Clear();

            period = totalFrames / 2;

            int sidecount = Math.Max(1, (int)Math.Ceiling(Math.Sqrt(count)));

            Size size = new Size(imageDescriptor.Width / sidecount, imageDescriptor.Height / sidecount);

            for (int i = 0; i < sidecount; i++)
            {
                for (int j = 0; j < sidecount; j++)
                {
                    int index = (i * sidecount + j);
                    if (index > count - 1)
                    {
                        continue;
                    }

                    Rectangle bounds = new Rectangle(j * size.Width, i * size.Height, size.Width, size.Height);

                    int age = start + ((count - 1 - index) * interval);

                    DelaySubframeConstant subframe = new DelaySubframeConstant(bounds, age);
                    subframes.Add(subframe);
                }
            }
        }
        public int GetAge(IDelaySubframe subframe)
        {
            if (!needsRefresh)
            {
                throw new InvalidOperationException("NeedsRefresh should have been tested before calling GetAge");
            }

            DelaySubframeConstant dsc = subframe as DelaySubframeConstant;

            return(dsc.Age);
        }
示例#3
0
 public int GetAge(IDelaySubframe subframe)
 {
     if (subframe is DelaySubframeConstant)
     {
         DelaySubframeConstant dsc = subframe as DelaySubframeConstant;
         return(dsc.Age);
     }
     else if (subframe is DelaySubframeVariable)
     {
         DelaySubframeVariable dsv = subframe as DelaySubframeVariable;
         return(dsv.GetAge(currentPosition, totalFrames));
     }
     else
     {
         return(0);
     }
 }
示例#4
0
        private void SetConfiguration(ImageDescriptor imageDescriptor, int totalFrames, int count)
        {
            if (imageDescriptor == null || imageDescriptor == ImageDescriptor.Invalid)
            {
                return;
            }

            int interval = 0;

            if (count != 1)
            {
                interval = (int)Math.Floor(totalFrames / (count - 1.0f));
            }

            subframes.Clear();

            int sidecount = Math.Max(1, (int)Math.Ceiling(Math.Sqrt(count)));

            Rectangle source = new Rectangle(0, 0, imageDescriptor.Width, imageDescriptor.Height);
            Size      size   = new Size(imageDescriptor.Width / sidecount, imageDescriptor.Height / sidecount);

            for (int i = 0; i < sidecount; i++)
            {
                for (int j = 0; j < sidecount; j++)
                {
                    int index = (i * sidecount + j);
                    if (index > count - 1)
                    {
                        continue;
                    }

                    int age = index * interval;

                    Rectangle             destination = new Rectangle(j * size.Width, i * size.Height, size.Width, size.Height);
                    DelaySubframeConstant subframe    = new DelaySubframeConstant(source, destination, age);
                    subframes.Add(subframe);
                }
            }
        }
示例#5
0
        private void SetConfiguration(ImageDescriptor imageDescriptor, int totalFrames, int count)
        {
            subframes.Clear();
            currentPosition = 0;
            int sidecount = Math.Max(1, (int)Math.Ceiling(Math.Sqrt(count)));

            Rectangle source      = new Rectangle(0, 0, imageDescriptor.Width, imageDescriptor.Height);
            Size      size        = new Size(imageDescriptor.Width / sidecount, imageDescriptor.Height / sidecount);
            Rectangle destination = new Rectangle(0, 0, size.Width, size.Height);

            DelaySubframeConstant subframe0 = new DelaySubframeConstant(source, destination, 0);

            subframes.Add(subframe0);

            destination = new Rectangle(size.Width, 0, size.Width, size.Height);
            DelaySubframeConstant subframe1 = new DelaySubframeConstant(source, destination, totalFrames);

            subframes.Add(subframe1);

            // Slow motion.

            int cycleDuration = (int)Math.Round(totalFrames * refreshRate);
            int shift         = (int)Math.Round((float)(totalFrames - cycleDuration) / (slowMotionImageCount - 1));

            int startPosition = 0;

            destination = new Rectangle(0, size.Height, size.Width, size.Height);
            DelaySubframeVariable subframe2 = new DelaySubframeVariable(source, destination, refreshRate, totalFrames, startPosition, cycleDuration);

            subframes.Add(subframe2);

            destination    = new Rectangle(size.Width, size.Height, size.Width, size.Height);
            startPosition += shift;
            DelaySubframeVariable subframe3 = new DelaySubframeVariable(source, destination, refreshRate, totalFrames, startPosition, cycleDuration);

            subframes.Add(subframe3);
        }
示例#6
0
        public int GetAge(IDelaySubframe subframe)
        {
            DelaySubframeConstant dsc = subframe as DelaySubframeConstant;

            return(dsc.Age);
        }