private void SetConfiguration(ImageDescriptor imageDescriptor, int totalFrames)
        {
            subframes.Clear();
            currentPosition = 0;

            // Each substream can only consume that many contiguous frames from the buffer.
            refreshRate = Math.Min(refreshRate, 1.0f);
            int cycleDuration = (int)Math.Round(totalFrames * refreshRate);
            int startPosition = 0;

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

            subframes.Add(subframe);
        }
Exemple #2
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);
     }
 }
Exemple #3
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);
        }
        private void SetConfiguration(ImageDescriptor imageDescriptor, int totalFrames, int count)
        {
            subframes.Clear();
            currentPosition = 0;
            int sidecount = Math.Max(1, (int)Math.Ceiling(Math.Sqrt(count)));

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

            // Each substream can only consume that many contiguous frames from the buffer.
            refreshRate = Math.Min(refreshRate, 1.0f);
            int cycleDuration = (int)Math.Round(totalFrames * refreshRate);

            // Each substream will start staggered by this amount.
            // If shift is less than cycle duration, we are going to miss some frames.
            int shift = (int)Math.Round((float)(totalFrames - cycleDuration) / (count - 1));

            covered = shift <= cycleDuration;

            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 startPosition = index * shift;

                    Rectangle             bounds   = new Rectangle(j * size.Width, i * size.Height, size.Width, size.Height);
                    DelaySubframeVariable subframe = new DelaySubframeVariable(bounds, refreshRate, totalFrames, startPosition, cycleDuration);
                    subframes.Add(subframe);
                }
            }
        }
        public int GetAge(IDelaySubframe subframe)
        {
            DelaySubframeVariable dsv = subframe as DelaySubframeVariable;

            return(dsv.GetAge(currentPosition, totalFrames));
        }