开发者

WPF/Silverlight: Instantly render large amounts of multi-colored text

开发者 https://www.devze.com 2022-12-14 04:34 出处:网络
I need to constantly display large amounts of colored text in WPF or Silverlight, and I need the user to percieve it as showing up instantly.

I need to constantly display large amounts of colored text in WPF or Silverlight, and I need the user to percieve it as showing up instantly.

Currently I'm doing this using a canvas and textblocks, one textblock per 80-character line, with multiple runs to a textblock to handle the different colors. There can often be 20+ runs to a line.

In a 45x80 grid 开发者_如何学JAVAof text, this gets a framerate of about 12 in Silverlight, which is sluggish. Oddly enough, it's even slower in WPF... I can only speculate that this has something to do with my dev machine's lousy video card. Maybe it's trying to hardware accelerate and actually slowing down because of it?

So, my question is: is there a better way to do this?


The best way to do this is to pre-render the text to a bitmap, cache the bitmap, and then blit it to the display. The framerate will go way up.

0

精彩评论

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