File tree 1 file changed +3
-4
lines changed
QuickLook.Plugin/QuickLook.Plugin.ImageViewer/NativeMethods
1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,7 @@ public static void SetClipboardImage(this BitmapSource img)
21
21
var thread = new Thread ( ( img ) =>
22
22
{
23
23
if ( img == null )
24
- {
25
24
return ;
26
- }
27
25
28
26
var image = ( BitmapSource ) img ;
29
27
@@ -36,15 +34,16 @@ public static void SetClipboardImage(this BitmapSource img)
36
34
try
37
35
{
38
36
using var pngMemStream = new MemoryStream ( ) ;
39
- using var bitmpa = image . ToBitmap ( ) ;
37
+ using var bitmpa = image . Dispatcher ? . Invoke ( ( ) => image . ToBitmap ( ) ) ?? image . ToBitmap ( ) ;
40
38
var data = new DataObject ( ) ;
41
39
42
40
bitmpa . Save ( pngMemStream , ImageFormat . Png ) ;
43
41
data . SetData ( "PNG" , pngMemStream , false ) ;
44
42
45
43
Clipboard . SetDataObject ( data , true ) ;
46
44
}
47
- catch { }
45
+ catch { } // Clipboard competition leading to failure is common
46
+ // There is currently no UI notification of success or failure
48
47
} ) ;
49
48
thread . SetApartmentState ( ApartmentState . STA ) ;
50
49
thread . Start ( img ) ;
You can’t perform that action at this time.
0 commit comments