简体   繁体   English

Windows应用商店中的叠加位图(writeablebitmap等)

[英]Overlay bitmaps (writeablebitmap etc.) in windows store app

I have 2 bitmaps (foreground and background) which I need to overlay on top of each other to form a new bitmap and use it as the ImageBrush for a button. 我有2个位图(前景图和背景图),需要彼此叠加以形成新的位图,并将其用作按钮的ImageBrush。 The code would look something like this (Windows 8.1 store app): 代码看起来像这样(Windows 8.1应用商店应用程序):

WriteableBitmap foregroundBitmap = GetForegroundBitmap();
WriteableBitmap backgroundBitmap = GetBackgroundBitmap();
ImageBrush imageBrush = new ImageBrush();
imageBrush.ImageSource = Overlay(foregroundBitmap, backgroundBitmap); 
Button button = new Button();
button.Background = imageBrush;

How can I implement the Overlay(...) method above? 如何实现上面的Overlay(...)方法?

I tried: 我试过了:

backgroundBitmap.Blit(
    new Rect(0, 0, backgroundBitmap.PixelWidth, backgroundBitmap.PixelHeight),
    foregroundBitmap,
    new Rect(0, 0, foregroundBitmap.PixelWidth, foregroundBitmap.PixelHeight),
    WriteableBitmapExtensions.BlendMode.None);

but it didn't work (with BlendedMode None or Additive). 但它不起作用(对于BlendedMode None或Additive)。

Thanks. 谢谢。

Try this 尝试这个

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

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

相关问题 使用Windows应用商店应用获取CPU使用率(等) - Get CPU-usage (etc.) with Windows Store Apps 在Windows Phone App 8.1中创建WriteableBitmap? - Create WriteableBitmap in windows phone app 8.1? 在Windows 8 / RT应用中处理位图 - Handling Bitmaps in Windows 8/RT app 从Windows应用程序管理asp.net网站(创建新用户,将用户分配给角色等) - Administer asp.net website (create new users, assign users to roles, etc.) from a windows app 如何调整WriteableBitmap的像素大小(windows store c#) - How to resize pixel of WriteableBitmap (windows store c#) 在Windows Phone 8应用程序中不使用WriteableBitmap或类似工具将位图转换为jpeg吗? - Convert bitmap to jpeg without using WriteableBitmap or similar in Windows Phone 8 app? 如何存储大量的WriteableBitmap? - How to store a lot of WriteableBitmap? 用于获取启动路径,应用程序数据路径等的WPF与“ System.Windows.Forms.Application.X”等效吗? - What is the WPF equivalent to “System.Windows.Forms.Application.X” for obtaining startup path, app data path, etc.? MonoGame Windows 8 - WriteableBitmap - MonoGame Windows 8 - WriteableBitmap .NET如何创建和执行其Windows,按钮等? - How does .NET create and execute its Windows, buttons, etc.?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM