冻结视觉画笔?或者有更好的主意吗?
我想为我的 UI 创建一个拇指图片分支,我尝试这样做:
RenderTargetBitmap renderer = new RenderTargetBitmap(WIDTH, HEIGHT, dpiX, dpiY, PixelFormats.Pbgra32);
renderer.Render(vbox);
renderer.Freeze();
“vbox”是我的 UIElement,它是在后台线程中创建的,我需要将其渲染为位图以在中显示主 UI 线程。将“vbox”渲染为位图后,我不会在任何地方使用它。
这些代码有效,但后来我发现我对它不满意,因为如果我放大拇指图片的尺寸,它看起来很糟糕。
我希望我可以使用矢量图形之类的东西,所以我尝试以这种方式做到这一点:
var visualBrush = new VisualBrush(vbox);
visualBrush.Stretch = Stretch.Uniform;
visualBrush.Freeze();
当然,这不起作用,因为我无法使用为其 Visual 属性指定除 Null 之外的任何值来冻结视觉画笔。
有人可以帮我吗?非常感谢。
欢呼
亚历克斯
I want to create a branch of thumb pictures for my UI, and I tried to do it in this way:
RenderTargetBitmap renderer = new RenderTargetBitmap(WIDTH, HEIGHT, dpiX, dpiY, PixelFormats.Pbgra32);
renderer.Render(vbox);
renderer.Freeze();
"vbox" is my UIElement, it is created in a background thread and I need to render it to a bitmap to show it in main UI thread. I won't use "vbox" anywhere after finishing rendering it to bitmap.
Those codes worked but then I found I wasn'6t satisfied with it because it looked bad if I enlarge the size of thumb picture.
I hope I can use something like vector graphic, so I tried to do it in this way:
var visualBrush = new VisualBrush(vbox);
visualBrush.Stretch = Stretch.Uniform;
visualBrush.Freeze();
Of course this didn't work because I couldn't freeze a visual brush with it's Visual property assigned any value other than Null.
Can anyone help me out? Thank you very much.
cheers
Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用(反)序列化来创建 VisualBrush 的单独副本。请参阅此答案
You can use (de)serialization to create individual copy of VisualBrush. See this answer