Jai*_*Oro 18 .net c# wpf bitmapsource bitmapimage
我需要解析Clipboard.GetImage()(a BitmapSource)的内容到a BitmapImage.有谁知道怎么做?
Jai*_*Oro 32
我发现了一个干净的解决方案:
BitmapSource bitmapSource = Clipboard.GetImage();
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
MemoryStream memoryStream = new MemoryStream();
BitmapImage bImg = new BitmapImage();
encoder.Frames.Add(BitmapFrame.Create(bitmapSource));
encoder.Save(memoryStream);
memoryStream.Position = 0;
bImg.BeginInit();
bImg.StreamSource = memoryStream;
bImg.EndInit();
memoryStream.Close();
return bImg;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
37955 次 |
| 最近记录: |