From 7c1bc144b6b5643786d424643f776f445a6405aa Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 16 Dec 2014 20:24:04 +1000 Subject: [PATCH] Remove SetBitmapHelper method - call code inline for now --- CefSharp.Wpf/ChromiumWebBrowser.cs | 37 +++++++++++++----------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index 5fed32a12..3facc08a7 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -1235,7 +1235,22 @@ namespace CefSharp.Wpf var img = bitmapInfo.IsPopup ? popupImage : image; // Now update the WPF image - SetBitmapHelper(bitmapInfo, img, bytesPerPixel); + var bitmap = bitmapInfo.InteropBitmap as InteropBitmap; + if (bitmap == null) + { + img.Source = null; + GC.Collect(1); + + var stride = bitmapInfo.Width * bytesPerPixel; + + bitmap = (InteropBitmap)Imaging.CreateBitmapSourceFromMemorySection(bitmapInfo.FileMappingHandle, + bitmapInfo.Width, bitmapInfo.Height, PixelFormat, stride, 0); + img.Source = bitmap; + } + + bitmap.Invalidate(); + + bitmapInfo.InteropBitmap = bitmap; } } @@ -1247,26 +1262,6 @@ namespace CefSharp.Wpf return pixelPosition; } - private static void SetBitmapHelper(BitmapInfo bitmapInfo, Image img, int bytesPerPixel) - { - var bitmap = bitmapInfo.InteropBitmap as InteropBitmap; - if (bitmap == null) - { - img.Source = null; - GC.Collect(1); - - var stride = bitmapInfo.Width * bytesPerPixel; - - bitmap = (InteropBitmap)Imaging.CreateBitmapSourceFromMemorySection(bitmapInfo.FileMappingHandle, - bitmapInfo.Width, bitmapInfo.Height, PixelFormat, stride, 0); - img.Source = bitmap; - } - - bitmap.Invalidate(); - - bitmapInfo.InteropBitmap = bitmap; - } - public void ViewSource() { managedCefBrowserAdapter.ViewSource();