Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions CefSharp.Wpf/Rendering/InteropBitmapInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

using System;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
Expand Down Expand Up @@ -31,14 +32,25 @@ public override void ClearBitmap()

public override void Invalidate()
{
Bitmap.Invalidate();
if (Bitmap != null)
{
Bitmap.Invalidate();
}
}

public override BitmapSource CreateBitmap()
{
var stride = Width * BytesPerPixel;

Bitmap = (InteropBitmap)Imaging.CreateBitmapSourceFromMemorySection(FileMappingHandle, Width, Height, PixelFormat, stride, 0);
// Unable to create bitmap without valid File Handle (Most likely control is being disposed)
if (FileMappingHandle == IntPtr.Zero)
{
return null;
}
else
{
Bitmap = (InteropBitmap)Imaging.CreateBitmapSourceFromMemorySection(FileMappingHandle, Width, Height, PixelFormat, stride, 0);
}

return Bitmap;
}
Expand Down