WPF - 将容器的内容克隆为几何图形
好吧,我在使用视觉画笔尝试从大画布的各个部分打印页面时运气不佳。一般情况下可以工作,但往往会栅格化某些部分并产生不良输出。 (我之前曾问过相关问题)。
因此,现在我正在创建一堆具有所有相同内容的画布副本,并缩小到各个部分以作为单页打印。这是可行的,但显然很慢,并且随着页面的增加只会变得更慢。
那么,可能有效的方法是,是否有某种方法可以执行类似于视觉画笔的操作,但让它将其“视图”中的内容复制为某种新的几何对象?我的画布的内容是线条、图像等的组合,所以最好能够定义画笔的视图并告诉它将所有可见的矢量和光栅对象的交集副本复制到一个新的某种容器。
这将允许我使用单个画布,并在不同位置拍摄内容的“快照”,以用于打印各个页面。
Ok ive had a lot of bad luck using a visualbrush to try to print out pages from subsections of a large canvas. Works in general, but tends to rasterize some parts and creates bad output. (I've asked questions about this before).
So now I'm creating a bunch of copies of the canvas with all the same contents, and pinching down to invidual portions to print as a single page. This works, but obviously is slow and will only get slower with more pages.
So what might work well is, is there some way to do something similar toa visual brush, but to instead have it copy the contents from its "view" as a new geometry object of some kind? The contents of my canvas are a combination of lines, images, etc, so what would be nice is to be able to define the view of a brush and tell it to make an intersection copy of all the vector and raster objects visible into a new container of some kind.
This would allow me to use a single canvas, and take "snapshots" of the contents at different places to be used for printing the individual pages.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 RenderTargetBitmap 获取 Canvas 的位图副本,然后裁剪您想要的部分。如果您特别想要矢量副本,则需要将画布写入 XPS。
编辑:如果您想要矢量副本,您是否尝试过使用 XamlWriter.Save,编辑 Xaml,然后使用 XamlReader.Load?
You could use RenderTargetBitmap to get a bitmap copy of the Canvas, and then crop the portion you wanted. If you specifically want a vector copy you'd need to write the canvas out to XPS.
Edit: If you want a vector copy, have you tried using XamlWriter.Save, edit the Xaml, and then XamlReader.Load?