2014-01-08 2 views
1

2 개의 비트 맵 (전경 및 배경)이 서로 겹쳐서 새로운 비트 맵을 형성하고 단추의 ImageBrush로 사용해야합니다.Windows의 오버레이 비트 맵 (writeablebitmap 등)은 앱을 저장합니다

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

가 어떻게 오버레이 (...) 위의 방법을 구현할 수 있습니다 코드는이 (윈도우 8.1 스토어 앱)과 같을까요?

내가 시도 :

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

하지만 (BlendedMode 없음 또는 첨가제와 함께) 작동하지 않았다.

감사합니다.

답변

0

는 샘플이

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

감사를 사용해보십시오. 실제로 런타임시로드되는 50 개의 다양한 버튼이 있으며 XAML 대신 코드에서 수행해야합니다. 어쨌든, 내 코드에서 문제를 발견하고 지금 "blit"이 작동합니다. 다시 한번 감사드립니다. – alexbtr