2016-03-20 11 views
0

Elipse'de dolgu olarak kullanmam gereken bir görüntü var IRandomAccessStreamReference. Bunu kullanarak nasıl giderim?Şekil için IRandomAccessStreamReference öğesinde nasıl kullanılır?

... 
static IRandomAccessStreamReference myThumbnail; 
... 
var contactStore = await ContactManager.RequestStoreAsync(); 
var contact = await contactStore.GetMeContactAsync(); 
myThumbnail = contact.Thumbnail; 
... 
Ellipse ellipse = new Ellipse 
      { 

       Height = 32, 
       Width = 32, 
       Fill = myThumbnail, // How do I use this? 
      }; 

cevap

0

Yani, taban Brush sınıftan türetilmiş ImageBrush sınıfını kullanmak gerekir. Bu sınıf, BitmapImage için ImageSource özelliği, temel sınıfı içerir. Ayrıca, örneğin, BitmapImage sınıfı, DecodePixelWidth veya DecodePixelHeight özelliğini kullanmanızı öneririz.

var thumbailImageBrush = new ImageBrush(); 
using (var randomStream = await myThumbnail.OpenReadAsync()) 
{ 
    var bitmapImage = new BitmapImage(); 
    bitmapImage.DecodePixelWidth = 32; // just good practice 
    await bitmapImage.SetSourceAsync(randomStream); 
    thumbailImageBrush.ImageSource = bitmapImage; 
} 

var ellipse = new Ellipse 
{ 
    Height = 32, 
    Width = 32, 
    Fill = thumbailImageBrush 
}; 
İlgili konular