簡體   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