Image 组合图像平移、缩放和旋转(C#,XAML)

Image 组合图像平移、缩放和旋转(C#,XAML),image,winrt-xaml,scrollviewer,image-rotation,Image,Winrt Xaml,Scrollviewer,Image Rotation,我想显示用户提供的图像。这些图像可能大于屏幕分辨率(因此需要缩放和平移功能),加上图像可能无法在屏幕上正确定位(因此需要能够旋转) 实现平移和缩放似乎有些简单: <ScrollViewer HorizontalSnapPointsType="None" HorizontalScrollBarVisibility="Auto" VerticalSnapPointsType="None" ZoomSnapPointsType="None" IsHorizontalRailEnabled="Fa

我想显示用户提供的图像。这些图像可能大于屏幕分辨率(因此需要缩放和平移功能),加上图像可能无法在屏幕上正确定位(因此需要能够旋转)

实现平移和缩放似乎有些简单:

<ScrollViewer HorizontalSnapPointsType="None" HorizontalScrollBarVisibility="Auto" VerticalSnapPointsType="None" ZoomSnapPointsType="None" IsHorizontalRailEnabled="False" IsVerticalRailEnabled="False" ManipulationMode="All" VerticalScrollBarVisibility="Auto">
   <Image x:Name="pannableImage" Source="{Binding FullSizedImage}" AutomationProperties.Name="{Binding Title}" />
</ScrollViewer>

这很好,满足了我的需要,尽管我希望能够设置初始缩放因子,以便在图像大于屏幕时,设置缩放因子,使其填充屏幕;如果图像不大于屏幕,则设置缩放因子,使图像以全尺寸显示,即不放大

然而,我正在努力让轮换工作可以接受。我试过这个:

<ScrollViewer HorizontalSnapPointsType="None" HorizontalScrollBarVisibility="Auto" VerticalSnapPointsType="None" ZoomSnapPointsType="None" IsHorizontalRailEnabled="False" IsVerticalRailEnabled="False" ManipulationMode="All" VerticalScrollBarVisibility="Auto">
   <Image x:Name="pannableImage" Source="{Binding FullSizedImage}" AutomationProperties.Name="{Binding Title}" >
      <Image.Projection>
         <PlaneProjection RotationZ="{Binding ImageRotation}"/>
      </Image.Projection>
    </Image>
 </ScrollViewer>

虽然这确实会旋转图像,但问题是ScrollViewer会错误地滚动。我还尝试将投影放在ScrollViewer上,而不是图像上,这更糟糕

将项目放在图像上似乎最有意义,因为ScrollViewer应该获得投影图像的尺寸,但情况似乎并非如此

请问我在这里误解了什么

谢谢


Philip

解决方案是使用渲染转换而不是投影:

            <Image x:Name="pannableImage" Source="{Binding FullSizedImage}" ManipulationMode="All" Loaded="pannableImage_Loaded" IsDoubleTapEnabled="False" IsHitTestVisible="False" IsHoldingEnabled="False" IsRightTapEnabled="False" IsTapEnabled="False" ScrollViewer.VerticalScrollBarVisibility="Disabled" LayoutUpdated="pannableImage_LayoutUpdated">
                <Image.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform x:Name="Scale" />
                        <RotateTransform x:Name="Rotate" />
                        <TranslateTransform x:Name="Translate" />
                    </TransformGroup>
                </Image.RenderTransform>
            </Image>