wieslawsoltes / PanAndZoom

Pan and zoom control for Avalonia.
http://wieslawsoltes.github.io/PanAndZoom/
MIT License
337 stars 44 forks source link

Performance issues when using large images #33

Closed sn4k3 closed 3 years ago

sn4k3 commented 4 years ago
<paz:ZoomBorder Name="zoomBorder" Stretch="None" ZoomSpeed="1.2"
                        Background="SlateBlue" ClipToBounds="True" Focusable="True"
                        VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                        Grid.Row="4" Grid.Column="1">
        <Image Name="img"/>
      </paz:ZoomBorder>

Have done a simple test and loaded a 2560x1440 black and white image, the pan and zoom gets very slow as it zoom in more, also image gets blury at high zoom levels. Is there anything i can add to get better performance?

wieslawsoltes commented 4 years ago

Is this WPF or Avalonia ? You can probably change image quality when zooming, to speed things up, but this will result in worse rendering quality and faster speeds.

sn4k3 commented 4 years ago

Is this WPF or Avalonia ? You can probably change image quality when zooming, to speed things up, but this will result in worse rendering quality and faster speeds.

It's Avalonia, the bigger the image the worst performance is, even to pan... Also image distorcing pixels, they get blury, this make this component not so good to use since it kill the user interaction. Back on WinForms i use https://github.com/cyotek/Cyotek.Windows.Forms.ImageBox which no matter the resolution, renders (pan/zoom) are always instants (no delay) and never distorce pixels. Since WPF is made for graphics i never expected that to be worst than a WinForm bitmap zoom/pan component :(

I'm attaching a test image if you want give it a try, for me it's laggy to zoom and pan, with blur edges/pixels

body_Tough0 1mm_SL1_5h16m_HOLLOW_DRAIN00013

wieslawsoltes commented 3 years ago

@sn4k3 Please take a look at proposed solution here https://github.com/AvaloniaUI/Avalonia/issues/2849

Bastani commented 3 years ago

For anyone looking for a solution, you have to add the following lines to your program.cs file in Avalonia

image

Increase MaxGpuResourceSizeBytes to fit your needs

dbriard commented 1 year ago

For anyone looking for a solution, you have to add the following lines to your program.cs file in Avalonia

image

Increase MaxGpuResourceSizeBytes to fit your needs

A big thanks to you for MaxGpuResourceSizeBytes trick!