C# 在windows应用商店应用程序中覆盖位图(可写位图等)

C# 在windows应用商店应用程序中覆盖位图(可写位图等),c#,windows-store-apps,windows-8.1,writeablebitmap,blit,C#,Windows Store Apps,Windows 8.1,Writeablebitmap,Blit,我有两个位图(前景和背景),我需要将它们相互叠加以形成一个新位图,并将其用作按钮的图像笔刷。 代码如下所示(Windows 8.1应用商店应用程序): 如何实现上面的Overlay(…)方法 我试过: backgroundBitmap.Blit( new Rect(0, 0, backgroundBitmap.PixelWidth, backgroundBitmap.PixelHeight), foregroundBitmap, new Rect(0, 0, foregr

我有两个位图(前景和背景),我需要将它们相互叠加以形成一个新位图,并将其用作按钮的图像笔刷。 代码如下所示(Windows 8.1应用商店应用程序):

如何实现上面的Overlay(…)方法

我试过:

backgroundBitmap.Blit(
    new Rect(0, 0, backgroundBitmap.PixelWidth, backgroundBitmap.PixelHeight),
    foregroundBitmap,
    new Rect(0, 0, foregroundBitmap.PixelWidth, foregroundBitmap.PixelHeight),
    WriteableBitmapExtensions.BlendMode.None);
但它不起作用(使用BlendedModeNone或Additional)

谢谢。

试试这个

 <Window.Resources>
    <BitmapImage x:Key="image1" UriSource="DefaultImage.png"></BitmapImage>
    <BitmapImage x:Key="image2" UriSource="ImageRoation.png"></BitmapImage>
 </Window.Resources>

<Button Height="200" Width="200">
    <Grid Height="200" Width="200">
        <Grid.Background>
            <ImageBrush ImageSource="{StaticResource image1}" Stretch="Fill" ></ImageBrush>
        </Grid.Background>
        <Grid Margin="5" Width="50" Height="50"> 
            <Grid.Background>
                <ImageBrush ImageSource="{StaticResource image2}" Stretch="Fill"></ImageBrush>
            </Grid.Background>
        </Grid>
    </Grid>
</Button>

谢谢您的示例。实际上,我在运行时加载了大约50个这样的按钮,需要用代码而不是XAML来完成。无论如何,我在代码中发现了问题,现在“blit”可以工作了。再次感谢。
 <Window.Resources>
    <BitmapImage x:Key="image1" UriSource="DefaultImage.png"></BitmapImage>
    <BitmapImage x:Key="image2" UriSource="ImageRoation.png"></BitmapImage>
 </Window.Resources>

<Button Height="200" Width="200">
    <Grid Height="200" Width="200">
        <Grid.Background>
            <ImageBrush ImageSource="{StaticResource image1}" Stretch="Fill" ></ImageBrush>
        </Grid.Background>
        <Grid Margin="5" Width="50" Height="50"> 
            <Grid.Background>
                <ImageBrush ImageSource="{StaticResource image2}" Stretch="Fill"></ImageBrush>
            </Grid.Background>
        </Grid>
    </Grid>
</Button>