WPF:如何prevent与WriteableBitmap的撕裂? [英] WPF: How do I prevent tearing with WriteableBitmap?

查看:568
本文介绍了WPF:如何prevent与WriteableBitmap的撕裂?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是<一href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspx"><$c$c>WriteableBitmap以每秒约20帧,以显示我处理自己的图像。

I'm using a WriteableBitmap to display images I process myself at around 20 frames per second.

此问题(<一href="http://stackoverflow.com/questions/893324/wpf-more-efficient-way-of-displaying-quickly-changing-images">WPF:
显示快速变化的图像?)的更有效的方法 而这个问题(<一href="http://stackoverflow.com/questions/812288/how-to-display-quick-updating-images-without-large-memory-allocation">How没有大的内存分配,以显示快速更新图像?)
表明,要做到这一点的最好办法是使用 WriteableBitmap的

This question (WPF: More efficient way of displaying quickly-changing images?)
and this question (How to display quick-updating images without large memory allocation?)
indicate that the best way to do this is by using a WriteableBitmap.

的文档 WriteableBitmap的表示调用 WritePixels() UI线程会导致渲染线程重绘上图片:

The documentation for WriteableBitmap indicates that calling WritePixels() on the UI thread will cause the rendering thread to redraw the image:

MSDN文档:
的UI线程写入内容到后台缓冲区。渲染线程读取来自前台缓冲区并将其复制到视频内存的内容。更改到后台缓冲区跟踪与改变的矩形区域。

&LT;喀嚓/>

当更新发送到渲染线程,渲染线程拷贝改变的矩形从后台缓冲区到前台缓冲区。渲染系统控制此交换,以避免死锁和重绘文物,如撕裂。

我处理在后台线程我的图片,然后使用 Dispatcher.BeginInvoke()来调用 WritePixels() ,以确保 WritePixels()被称为UI线程。

I process my images on a background thread, then use Dispatcher.BeginInvoke() to call WritePixels(), to ensure that WritePixels() is called on the UI thread.

我发现撕裂仍然出现 WriteableBitmap的,并在应用我的工作,它看起来可怕的(其医疗成像应用程序)。有什么我可以做什么?

I'm finding that tearing still occurs with WriteableBitmap, and in the application I'm working on, it looks awful (its a medical imaging application). Is there anything I can do?

推荐答案

有大量的工作投入WriteableBitmap的,以避免撕裂,但在某些系统配置,这是不可避免的。这主要将发生在Windows XP或Vista瓦特/航空(DWM)关闭。

There was a lot of work put into WriteableBitmap to avoid tearing, but on some system configurations this is unavoidable. This mostly will happen on Windows XP or Vista w/ Aero (DWM) turned off.

这篇关于WPF:如何prevent与WriteableBitmap的撕裂?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆