/// <summary>
        /// Invoked from CefRenderHandler.OnPaint
        /// Locking provided by OnPaint as this method is called in it's lock scope
        /// </summary>
        /// <param name="bitmapInfo">information about the bitmap to be rendered</param>
        void IRenderWebBrowser.InvokeRenderAsync(BitmapInfo bitmapInfo)
        {
            var gdiBitmapInfo = (GdiBitmapInfo)bitmapInfo;
            if (bitmapInfo.CreateNewBitmap)
            {
                if (bitmap != null)
                {
                    bitmap.Dispose();
                    bitmap = null;
                }

                bitmap = gdiBitmapInfo.CreateBitmap();
            }

            var handler = NewScreenshot;
            if (handler != null)
            {
                handler(this, EventArgs.Empty);
            }
        }
示例#2
0
 /// <summary>
 /// Invoked from CefRenderHandler.OnPaint
 /// Locking provided by OnPaint as this method is called in it's lock scope
 /// </summary>
 /// <param name="bitmapInfo">information about the bitmap to be rendered</param>
 void IRenderWebBrowser.InvokeRenderAsync(BitmapInfo bitmapInfo)
 {
     InvokeRenderAsync(bitmapInfo);
 }
        void IRenderWebBrowser.InvokeRenderAsync(BitmapInfo bitmapInfo)
        {
            UiThreadRunAsync(delegate
            {
                lock (bitmapInfo.BitmapLock)
                {
                    var wpfBitmapInfo = (WpfBitmapInfo)bitmapInfo;
                    // Inform parents that the browser rendering is updating
                    OnRendering(this, wpfBitmapInfo);

                    // Now update the WPF image
                    if (wpfBitmapInfo.CreateNewBitmap)
                    {
                        var img = bitmapInfo.IsPopup ? popupImage : image;

                        img.Source = null;
                        GC.Collect(1);

                        img.Source = wpfBitmapInfo.CreateBitmap();
                    }

                    wpfBitmapInfo.Invalidate();
                }
            },
            DispatcherPriority.Render);
        }
示例#4
0
        /// <summary>
        /// Invoked from CefRenderHandler.OnPaint
        /// A new <see cref="Bitmap" /> is only created when <see cref="BitmapInfo.CreateNewBitmap" />
        /// is true, otherwise the new buffer is simply copied into the backBuffer of the existing
        /// <see cref="Bitmap" /> for efficiency. Locking provided by OnPaint as this method is called
        /// in it's lock scope.
        /// </summary>
        /// <param name="bitmapInfo">information about the bitmap to be rendered</param>
        public virtual void InvokeRenderAsync(BitmapInfo bitmapInfo)
        {
            var gdiBitmapInfo = (GdiBitmapInfo)bitmapInfo;

            if (bitmapInfo.CreateNewBitmap)
            {
                if (gdiBitmapInfo.IsPopup)
                {
                    if (Popup != null)
                    {
                        Popup.Dispose();
                        Popup = null;
                    }

                    Popup = gdiBitmapInfo.CreateBitmap();
                }
                else
                {
                    if (Bitmap != null)
                    {
                        Bitmap.Dispose();
                        Bitmap = null;
                    }

                    Bitmap = gdiBitmapInfo.CreateBitmap();
                }
            }
        }
示例#5
0
        /// <summary>
        /// Invoked from CefRenderHandler.OnPaint
        /// A new <see cref="Bitmap" /> is only created when <see cref="BitmapInfo.CreateNewBitmap" />
        /// is true, otherwise the new buffer is simply copied into the backBuffer of the existing
        /// <see cref="Bitmap" /> for efficiency. Locking provided by OnPaint as this method is called
        /// in it's lock scope.
        /// </summary>
        /// <param name="bitmapInfo">information about the bitmap to be rendered</param>
        void IRenderWebBrowser.InvokeRenderAsync(BitmapInfo bitmapInfo)
        {
            InvokeRenderAsync(bitmapInfo);

            var handler = NewScreenshot;
            if (handler != null)
            {
                handler(this, EventArgs.Empty);
            }
        }
 void IRenderWebBrowser.InvokeRenderAsync(BitmapInfo bitmapInfo)
 {
     IRenderWebBrowser renderer = this;
     DoInUi(() => renderer.SetBitmap(bitmapInfo), DispatcherPriority.Render);
 }
 void IRenderWebBrowser.SetBitmap(BitmapInfo bitmapInfo)
 {
     lock (bitmapInfo.BitmapLock)
     {
         if (bitmapInfo.IsPopup)
         {
             bitmapInfo.InteropBitmap = SetBitmapHelper(bitmapInfo,
                 (InteropBitmap)bitmapInfo.InteropBitmap, bitmap => popupImage.Source = bitmap);
         }
         else
         {
             bitmapInfo.InteropBitmap = SetBitmapHelper(bitmapInfo,
                 (InteropBitmap)bitmapInfo.InteropBitmap, bitmap => image.Source = bitmap);
         }
     }
 }
        private object SetBitmapHelper(BitmapInfo bitmapInfo, InteropBitmap bitmap, Action<InteropBitmap> imageSourceSetter)
        {
            if (bitmap == null)
            {
                imageSourceSetter(null);
                GC.Collect(1);

                var stride = bitmapInfo.Width * BytesPerPixel;

                bitmap = (InteropBitmap)Imaging.CreateBitmapSourceFromMemorySection(bitmapInfo.FileMappingHandle,
                    bitmapInfo.Width, bitmapInfo.Height, PixelFormat, stride, 0);
                imageSourceSetter(bitmap);
            }

            bitmap.Invalidate();

            return bitmap;
        }
 void IRenderWebBrowser.ClearBitmap(BitmapInfo bitmapInfo)
 {
     bitmapInfo.InteropBitmap = null;
 }
示例#10
0
        void IRenderWebBrowser.InvokeRenderAsync(BitmapInfo bitmapInfo)
        {
            lock (bitmapLock)
            {
                if (bitmap != null)
                {
                    bitmap.Dispose();
                    bitmap = null;
                }

                var stride = bitmapInfo.Width * bitmapInfo.BytesPerPixel;

                bitmap = new Bitmap(bitmapInfo.Width, bitmapInfo.Height, stride, PixelFormat.Format32bppPArgb, bitmapInfo.BackBufferHandle);
                
                var handler = NewScreenshot;
                if (handler != null)
                {
                    handler(this, EventArgs.Empty);
                }
            }
        }
示例#11
0
 public void InvokeRenderAsync(BitmapInfo bitmapInfo)
 {
     DoInUi(() => SetBitmap(bitmapInfo), DispatcherPriority.Render);
 }
示例#12
0
 public void ClearBitmap(BitmapInfo bitmapInfo)
 {
     bitmapInfo.InteropBitmap = null;
 }
示例#13
0
        void IRenderWebBrowser.InvokeRenderAsync(BitmapInfo bitmapInfo)
        {
            UiThreadRunAsync(delegate
            {
                lock (bitmapInfo.BitmapLock)
                {
                    var interopBitmapInfo = (InteropBitmapInfo)bitmapInfo;
                    // Inform parents that the browser rendering is updating
                    OnRendering(this, interopBitmapInfo);

                    // Now update the WPF image
                    var bitmap = interopBitmapInfo.InteropBitmap;
                    if (bitmap == null)
                    {
                        var img = bitmapInfo.IsPopup ? popupImage : image;

                        img.Source = null;
                        GC.Collect(1);

                        var stride = bitmapInfo.Width * bitmapInfo.BytesPerPixel;

                        bitmap = (InteropBitmap)Imaging.CreateBitmapSourceFromMemorySection(bitmapInfo.FileMappingHandle,
                            bitmapInfo.Width, bitmapInfo.Height, PixelFormat, stride, 0);
                        img.Source = bitmap;

                        interopBitmapInfo.InteropBitmap = bitmap;
                    }

                    bitmap.Invalidate();
                }
            },
            DispatcherPriority.Render);
        }
示例#14
0
        /// <summary>
        /// Invoked from CefRenderHandler.OnPaint
        /// A new <see cref="Bitmap"/> is only created when <see cref="BitmapInfo.CreateNewBitmap"/>
        /// is true, otherwise the new buffer is simply copied into the backBuffer of the existing
        /// <see cref="Bitmap"/> for efficency. Locking provided by OnPaint as this method is called
        /// in it's lock scope.
        /// </summary>
        /// <param name="bitmapInfo">information about the bitmap to be rendered</param>
        public virtual void InvokeRenderAsync(BitmapInfo bitmapInfo)
        {
            var gdiBitmapInfo = (GdiBitmapInfo)bitmapInfo;
            if (bitmapInfo.CreateNewBitmap)
            {
                if (Bitmap != null)
                {
                    Bitmap.Dispose();
                    Bitmap = null;
                }

                Bitmap = gdiBitmapInfo.CreateBitmap();
            }

            var handler = NewScreenshot;
            if (handler != null)
            {
                handler(this, EventArgs.Empty);
            }
        }