繁体   English   中英

循环图像旋转在WPF中最好的方法是什么

[英]round robin image rotation what is the best way to do in WPF

我正在寻找在wpf中执行此操作的最佳方法。 我已经问过这个问题,并得到了在opencv中实现它的答案。 循环图像旋转在opencv中最好的方法是什么

在wpf中执行此操作的最佳方法是什么。
显然,我可以创建一个writableBitmap并手动复制像素,但是我认为这不是最好的方法。

编辑1

为了澄清我要问的问题:我喜欢使用WPF来实现与该SO问题( 轮循图像旋转是在opencv中最好的方法是什么)中建议的算法相同。

在WPF中做到这一点的最佳方法是有效的(内存和速度)。

您可以使用ImageBrush在矩形上绘制,并调整画笔的ViewPort属性以滑动图像。 如果要使用此动画,请使用WPF中的XAML示例,该示例使用动画自动调整画笔的视口属性并执行幻灯片动画。 希望这会有所帮助。

<Window x:Class="TestWpfApplication.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
    <Grid>
        <Rectangle>
            <Rectangle.Fill>
                <DrawingBrush x:Name="MyBrush" Viewport="0,0,1,1" TileMode="Tile">
                    <DrawingBrush.Drawing>
                        <DrawingGroup>
                            <GeometryDrawing>
                                <GeometryDrawing.Geometry>
                                    <GeometryGroup>
                                        <RectangleGeometry Rect="0,0,100,100" />
                                    </GeometryGroup>
                                </GeometryDrawing.Geometry>
                                <GeometryDrawing.Brush>
                                    <ImageBrush ImageSource="lSXfX.png" />
                                </GeometryDrawing.Brush>
                            </GeometryDrawing>
                        </DrawingGroup>
                    </DrawingBrush.Drawing>
                </DrawingBrush>
            </Rectangle.Fill>
            <Rectangle.Triggers>
                <EventTrigger RoutedEvent="Rectangle.Loaded">
                    <BeginStoryboard>
                        <Storyboard>
                            <RectAnimation
                            Storyboard.TargetName="MyBrush" 
                            Storyboard.TargetProperty="Viewport"
                            From="0 0 1 1" To="1 0 1 1" Duration="0:0:10"
                            RepeatBehavior="Forever" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Rectangle.Triggers>
        </Rectangle>
    </Grid>
</Window>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM