Effectively display and scale / pan large images in WPF

I am currently working on an application with the need to display large engineering drawings, which may be 8800x6800 or more. The requirements indicate that the user must be able to pan and zoom the image. Ideally, they would also like to annotate the images. If you look at the Windows Photo Viewer, you will see the performance and features that I'm going to emulate, minus the annotation part.

So far I have tried several different approaches for displaying images, and no one seems to offer the performance I'm looking for. Either they take a lot of memory, or they are slow. These are the approaches I have done:

  • Viewbox with Image as a child. Memory usage is fine, but Viewbox is slow. Because of this, I have not tried zooming / panning with this approach yet.
  • InkCanvas with Image set either as a background or as a child. With such an approximation, scaling / panning with ScaleTransform and TranslateTransform would seem like that, but memory usage could be in the range of 450-600 MB.

This is my first foray into image manipulation with .NET / WPF, and my knowledge on this is rather limited. What are some best practices for working with large images, especially with WPF? I read that image tiles (such as deep zoom) can help, but was not sure how to do this or if this is the best idea in my situation. Do you know any resources that could help me understand this better?

+4
source share
1 answer

Under the "tile", if you want to divide the image into separate parts and display only a small subset at once to improve performance, it will be called "virtualization".

Microsoft has a great blog about item virtualization and even provides a reference implementation of VirtualCanvas, which you can use as a starting point for a virtualized control.

Link here: http://blogs.msdn.com/b/jgoldb/archive/2008/03/08/performant-virtualized-wpf-canvas.aspx

Please note: this blog includes scale and scope as part of the discussion, as well as a discussion of smooth scrolling and proactive loading of fragments for a better interface response.

+1
source

Source: https://habr.com/ru/post/1348093/


All Articles