변환기를 사용하여 XAML에로드 된 이미지가 있습니다. 이 이미지를 다시로드하는 대신 이미지를 가져 와서 페이지의 다른 그래픽에 사용할 수있는 주 색상을 찾고 싶습니다. 지금까지이있다 :UWP BitmapImage to Stream
var himage = (BitmapImage)image_home.Source;
using (var stream = await himage.OpenReadAsync()) //**can't open himage this way**
{
//Create a decoder for the image
var decoder = await BitmapDecoder.CreateAsync(stream);
//Create a transform to get a 1x1 image
var myTransform = new BitmapTransform { ScaledHeight = 1, ScaledWidth = 1 };
//Get the pixel provider
var pixels = await decoder.GetPixelDataAsync(
BitmapPixelFormat.Rgba8,
BitmapAlphaMode.Ignore,
myTransform,
ExifOrientationMode.IgnoreExifOrientation,
ColorManagementMode.DoNotColorManage);
//Get the bytes of the 1x1 scaled image
var bytes = pixels.DetachPixelData();
//read the color
var myDominantColor = Color.FromArgb(255, bytes[0], bytes[1], bytes[2]);
}
분명히
내가 OpenReadAsync 사용하여 BitmapImage의 himage를 열 수 없습니다, 어떻게이를 달성 할 수 있도록 내가 거기에 어떻게해야합니까?
언급 한 변환기로 무엇을하고 있습니까? 같은 시간에 지배적 인 색을 추출 할 수 없습니까? –
죄송합니다. ID 번호를 이미지 소스 URL로 변환하는 바인드 변환기를 명시해야합니다. –