开发者

What is faster with PictureBox? Many small redraws or complete redraw

开发者 https://www.devze.com 2022-12-30 04:10 出处:网络
I have a PictureBox (WinMobile 6 WinForm) on which I draw some images. There is a background image that goes in the background and it does not change. However objects that are drawn on the picturebox

I have a PictureBox (WinMobile 6 WinForm) on which I draw some images. There is a background image that goes in the background and it does not change. However objects that are drawn on the picturebox are moving during the application so I need to refresh the background.

Since items that are redrawn fill from 50% to 80% of the surface, the question is which of the two is faster:

1) Redraw only parts of the background image that have been changed (previous+next loc开发者_StackOverflow社区ation of the moving object).

2) Redraw complete background and then draw all the objects in their current position.

Now, the reason for asking is because I am not sure how much of processor power is needed for a single drawImage operation and what are the time consuming factors.

I am aware if there is almost complete coverage of the background, it would be stupid to redraw portions of it, because by drawing portions I will have drawn the complete picture. But since sometimes only half of the image had changed (some objects remained in their old position), it may (perhaps) be benefitial to redraw only those regions. But I need your insight on this...

Thanks.


Less number of DrawImage is better, since it uses GDI+ to render and it goes very slow. I would recommend to use BitBlt of the old GDI instead of DrawImage.

With this you can put all necessary portions to a temporary canvas (Graphics obj) and then put everything into a PictureBox at once. If you ignore in your loop all portions that are outside of the visible screen, this should work fast.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号