【问题标题】:How to save an image to the clipboard only knowing the images path [duplicate]如何仅知道图像路径将图像保存到剪贴板[重复]
【发布时间】:2014-08-11 14:53:27
【问题描述】:

如果我有一个图像路径C:\MyImages\MyImage.jpg,我将如何使用 C# 将它放到剪贴板上。

我知道我会使用课程System.Windows.Clipboard.SetImage(); 但这需要 BitmapSource 作为参数。如何从给定路径获取 BitmapSource 对象以输入此方法?

【问题讨论】:

  • 作为重复站点的问题没有提到如何将图像放入剪贴板,这显然是问题的一部分。

标签: c# image clipboard bitmapsource


【解决方案1】:
BitmapSource bitmapSource = new BitmapImage(new Uri("C:\\MyImages\\MyImage.jpg"));
System.Windows.Clipboard.SetImage(bitmapSource);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 2011-04-19
    • 2023-02-21
    • 1970-01-01
    相关资源
    最近更新 更多