Beispiel #1
0
        /// <summary>
        /// Attempt to preallocate the circular buffer for as many images as possible that fits in available memory.
        /// </summary>
        public bool AllocateBuffers(ImageDescriptor imageDescriptor)
        {
            if (composite == null)
            {
                throw new InvalidOperationException();
            }

            if (!NeedsReallocation(imageDescriptor))
            {
                return(true);
            }

            Free();

            int         width       = imageDescriptor.Width;
            int         height      = imageDescriptor.Height;
            PixelFormat pixelFormat = PixelFormat.Format24bppRgb;

            try
            {
                image = new Bitmap(width, height, pixelFormat);
            }
            catch (Exception e)
            {
                log.ErrorFormat("Error while allocating delay compositer buffer.");
                log.Error(e);
            }

            if (image != null)
            {
                this.rect = new Rectangle(0, 0, width, height);

                this.allocated       = true;
                this.imageDescriptor = imageDescriptor;

                currentPosition = 0;
                composite.UpdateSubframes(imageDescriptor, delayer.Capacity);

                // Better do the GC now to push everything to gen2 and LOH rather than taking a hit later during normal streaming operations.
                GC.Collect(2);
            }

            return(allocated);
        }
Beispiel #2
0
 public void ResetComposite(IDelayComposite composite)
 {
     this.composite  = composite;
     currentPosition = 0;
     composite.UpdateSubframes(imageDescriptor, delayer.Capacity);
 }