【问题标题】:Generate an inverted (mirror image) of an image in wp8在 wp8 中生成图像的倒置(镜像)
【发布时间】:2015-06-01 11:04:09
【问题描述】:

我必须使用 c# 在 windows phone 8 中生成图像的镜像。我到目前为止所尝试的就在这里。我的 Xaml 代码:

<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
        <TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Button Name="submit" Grid.Row="0" Content="Select an Image" Tap="submit_Tap"/>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Image Name="mainImage" Stretch="Fill" Grid.Column="0" Height="500" Width="200"/>
            <Image Name="InvertedImage" Stretch="Fill" Grid.Column="1" Height="500" Width="200"/>
        </Grid>
        <Button Name="mirrorImage" Grid.Row="2" Content="Create Mirror Image" Tap="mirrorImage_Tap"/>
    </Grid>

`

还有我的 c# 代码:

private void submit_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
    PhotoChooserTask task = new PhotoChooserTask();
    task.Completed+=new EventHandler<PhotoResult>(task_Completed);
    task.Show();
}
BitmapImage mainImageSource = new BitmapImage();
private void task_Completed(object sender, PhotoResult e)
{
    if (e.TaskResult == TaskResult.OK)
    {
        mainImageSource.SetSource(e.ChosenPhoto);
        mainImage.Source = mainImageSource;
    }
}

private void mirrorImage_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
    InvertedImage.Source = mainImageSource;
}
}

在mirrorImage_Tap中。我必须在 InvertedImage 的源中设置倒置图像。帮助表示赞赏。

【问题讨论】:

    标签: c# image windows-phone-8 bitmapimage


    【解决方案1】:

    试试下面的代码

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Image Name="mainImage" Stretch="Fill" Grid.Column="0" Height="500" Width="200"/>
            <Image Name="InvertedImage" Stretch="Fill" Grid.Column="1" RenderTransformOrigin="0.5,0.5"Height="500" Width="200">
            <Image.RenderTransform>
                    <CompositeTransform ScaleX="-1"/>
                </Image.RenderTransform>
            </Image>
        </Grid>
    

    我认为图片上的&lt;CompositeTransform ScaleX="-1"/&gt; 会为您完成这项工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      • 2013-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多