2017-01-03 28 views

回答

1

使用在项目中的资源的图像,这似乎(使用WriteableBitmapEx

WriteableBitmap wb; 

private async void ImageOpened(object sender, RoutedEventArgs e) 
{ 
    wb = await BitmapFactory.New(1, 1).FromContent(((sender as Image).Source as BitmapImage).UriSource); 
} 

private async void ImageTapped(object sender, TappedRoutedEventArgs e) 
{ 
    var pos = e.GetPosition(sender as UIElement); 

    var px = wb.GetPixel((int)pos.X, (int)pos.Y); 

    System.Diagnostics.Debug.WriteLine($"R: {px.R} G: {px.G} B: {px.B} "); 
} 
+0

非常感谢。我已经尝试过WriteableBitmap类,但Visual Studio 2015将GetPixel方法标记为未定义。在Microsoft文档中,我也没有找到它。你的评论(使用WirteableBitmapEx)非常有帮助。现在我已经安装了WirteableBitmapEx软件包并且该方法可用。 –

+0

WriteableBitmapEx不是WirteableBitmapEx。 – lindexi

+0

@Lacey如果我从流中使用BitmapImage.SetSource,所以我不能使用UriSource.How可以将BitmapImage转换为writeableBitmap吗? – lindexi

相关问题