[英]Overlay bitmaps (writeablebitmap etc.) in windows store app
我有2個位圖(前景圖和背景圖),需要彼此疊加以形成新的位圖,並將其用作按鈕的ImageBrush。 代碼看起來像這樣(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;
如何實現上面的Overlay(...)方法?
我試過了:
backgroundBitmap.Blit(
new Rect(0, 0, backgroundBitmap.PixelWidth, backgroundBitmap.PixelHeight),
foregroundBitmap,
new Rect(0, 0, foregroundBitmap.PixelWidth, foregroundBitmap.PixelHeight),
WriteableBitmapExtensions.BlendMode.None);
但它不起作用(對於BlendedMode None或Additive)。
謝謝。
嘗試這個
<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.