locked
Simulating scrollViewer's behavior using DirectX

    Question

  • Hi,

    I'm working on a Windows store app. I have a SurfaceImageSource that I render to using DirectX. The content displayed is rather large, even though just a small part is displayed at once. So I'm trying to use a scrollViewer with an image in it that is binded to that SurfaceImageSource to let the user scroll an zoom.

    The problem is that I need to make the SurfaceImageSource very large to render all the content at once and to prevent it from getting blurred when zoomed in. It would be way more efficient if I could just respond to some kind of zooming and scrolling event and then to re-render the displayed content with a different transform.

    Does anyone understand me? :D Is there any way to achieve what I want without implementing every gesture and mouse input by Hand?


    Monday, April 28, 2014 4:46 PM

Answers

  • This sounds like a good use for a VirtualSurfaceImageSource rather than a SurfaceImageSource. That will allow rendering only the exposed part of the content rather then the whole thing. For more info on how to draw to a VirtualSurfaceImageSource, including sample code, see DirectX and XAML interop.

    --Rob

    Monday, April 28, 2014 8:17 PM
    Owner
  • I finally succeeded using the method described in the "PetzoldBookBlog" (can't post link, somehow). I use the VirtualSurfaceImageSource and resize it every time the ScrollViewer my image is in fires the ViewChanging Event, according to the zoom-factor passed. Then I change the DPI of the Direct2DContext.

    Flickers a bit, but it is ok.

    Thursday, May 8, 2014 5:22 PM

All replies

  • This sounds like a good use for a VirtualSurfaceImageSource rather than a SurfaceImageSource. That will allow rendering only the exposed part of the content rather then the whole thing. For more info on how to draw to a VirtualSurfaceImageSource, including sample code, see DirectX and XAML interop.

    --Rob

    Monday, April 28, 2014 8:17 PM
    Owner
  • This works well for scrolling. But is there any way I can keep the resolution high when zooming in?

    Monday, May 5, 2014 4:13 PM
  • I achieved this by using a swapchain, like described in the XAML SwapChainPanel DirectX interop sample.

    If I zoom in to far, like using a zoomfactor of 10, this seems to exceed the capabilities of my graphics card, the app crashes (ResizeBuffers returns e_invalidarg when passing a buffer size of 20000x20000). So is there any way to combine these two methods?


    Wednesday, May 7, 2014 4:47 PM
  • I finally succeeded using the method described in the "PetzoldBookBlog" (can't post link, somehow). I use the VirtualSurfaceImageSource and resize it every time the ScrollViewer my image is in fires the ViewChanging Event, according to the zoom-factor passed. Then I change the DPI of the Direct2DContext.

    Flickers a bit, but it is ok.

    Thursday, May 8, 2014 5:22 PM