我正在为我的图解应用程序制作复制和粘贴操作。所以我需要..。
注意,这需要WPF应用程序和本机Win-32之间的"Interop“。
如何做到这一点,尽可能短(两个功能,理想情况下)?
发布于 2011-10-21 06:36:49
您可能在过去半年中找到了答案,但下面是如何将WPF中的D3DImage转换为BitmapSource (本例中使用了vb.net ):
Public Function GetCurrentImage() As BitmapSource
Dim width As Integer = D3DImage.PixelWidth
Dim height As Integer = D3DImage.PixelHeight
Dim dv As New DrawingVisual()
Using dc As DrawingContext = dv.RenderOpen()
dc.DrawImage(D3DImage, New Rect(0, 0, width, height))
End Using
Dim rtb As New RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32)
rtb.Render(dv)
Return BitmapFrame.Create(rtb)
End Function您可以在C#中的WPFMediaKit中找到它。
发布于 2011-05-10 14:13:36
你说D3DImage是什么意思?
WPF中有一个“Control”/Surface,名为D3DImage,但感觉上好像是指位图格式。你想把数据放在剪贴板上吗?如果是这样的话你就不需要互交了。只需使用剪贴板API将图像放在剪贴板上,并从剪贴板中读取。
https://stackoverflow.com/questions/5907483
复制相似问题