Skip to content

Commit

Permalink
Merge d9f522b into ea843f3
Browse files Browse the repository at this point in the history
  • Loading branch information
remye06 authored Apr 5, 2019
2 parents ea843f3 + d9f522b commit 9c2c3b2
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions CefSharp.Wpf/ChromiumWebBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using CefSharp.Enums;
using CefSharp.Internals;
Expand Down Expand Up @@ -785,16 +787,29 @@ bool IRenderWebBrowser.StartDragging(IDragData dragData, DragOperationsMask allo
currentDragData = dragData.Clone();
currentDragData.ResetFileContents();

// TODO: The following code block *should* handle images, but GetFileContents is
// not yet implemented.
//if (dragData.IsFile)
//{
// var bmi = new BitmapImage();
// bmi.BeginInit();
// bmi.StreamSource = dragData.GetFileContents();
// bmi.EndInit();
// dataObject.SetImage(bmi);
//}
if (dragData.HasImage)
{
IImage dragImage = dragData.Image;
int width, height;
byte[] pixels = dragImage.GetAsBitmap(1f, ColorType.Rgba8888, AlphaType.PreMultiplied, out width, out height);
int stride = ((width * 32 + 31) & ~31) / 8;
var bitmap = BitmapSource.Create(width, height, 96.0, 96.0, PixelFormats.Pbgra32, null, pixels, stride);
bitmap.Freeze();
dataObject.SetImage(bitmap);
}
else
{
// TODO: The following code block *should* handle images, but GetFileContents is
// not yet implemented.
//if (dragData.IsFile)
//{
// var bmi = new BitmapImage();
// bmi.BeginInit();
// bmi.StreamSource = dragData.GetFileContents();
// bmi.EndInit();
// dataObject.SetImage(bmi);
//}
}

UiThreadRunAsync(delegate
{
Expand Down

0 comments on commit 9c2c3b2

Please sign in to comment.