从一个writablebitmap复制到另一个backable&花费太多时间 [英] copying from one writablebitmap to another back & forth taking too much time

查看:51
本文介绍了从一个writablebitmap复制到另一个backable&花费太多时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在实现一些功能,其中我们有一个writablebitmap,我们将其复制到中心位置的较大的writeablebitmap然后旋转它然后裁剪一些区域通过复制它。 

We are implementing some functionality wherein we have a writablebitmap which we copy to a bigger writeablebitmap in the center position and then rotate it and then crop some area out of it by copying it. 

所以,

位图 - >复制到大 - >旋转 - >裁剪(复制到其他人)

Bitmap --> Copy to big --> Rotate -> Crop (copy to other one)

这实际上会降低应用程序的性能。它阻止了UI线程,滑块上显示了很多延迟(Jerky)。

This is really degrading the performance of app. It blocks the UI thread and there is lot of lag shown on sliders(Jerky).

这是用于此的正确数据结构吗?我可以以某种方式优化它吗?请给出输入。

Is it right data structure to use for this? Can I optimize it somehow? Please give inputs.

谢谢。

推荐答案

如前所述,使用Win2D代替高性能图形比WriteableBitmap。

As previously recommended use Win2D for performant graphics rather than WriteableBitmap.

无论你采用哪种方式,都要尽量减少转换。复制WriteableBitmap的PixelBuffer会移动大量数据,因此应尽可能避免使用。在大多数需要频繁访问缓冲区的场景中,您可以缓存PixelBuffer并重复使用相同的
缓冲区进行多次操作,而不是每次都复制一份副本。 

Whichever way you go, minimize conversions. Copying a WriteableBitmap's PixelBuffer moves a lot of data and so should be avoided whenever possible. In most scenarios that need frequent access to the buffer you can cache the PixelBuffer and reuse the same buffer for multiple operations rather than snapping a copy each time. 


这篇关于从一个writablebitmap复制到另一个backable&花费太多时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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