C# WP8.1RT:从mediacapture C拍摄的自定义分辨率图像#
在浏览了整个网站后,我发现了一点问题的解决方法。我遇到的问题是,我正在尝试使用此(下载)中的mediacapture捕获图像 我在中发现了几个线程,它们已经可以处理分辨率了,但它们所做的是使用默认分辨率,如下所示C# WP8.1RT:从mediacapture C拍摄的自定义分辨率图像#,c#,xaml,windows-phone-8.1,windows-store-apps,C#,Xaml,Windows Phone 8.1,Windows Store Apps,在浏览了整个网站后,我发现了一点问题的解决方法。我遇到的问题是,我正在尝试使用此(下载)中的mediacapture捕获图像 我在中发现了几个线程,它们已经可以处理分辨率了,但它们所做的是使用默认分辨率,如下所示 3024*4992.......4:3 1936*2592...162:121 1536*2048.......4:3 480*640..........4:3 3024*5376.....16:9 1728*3072.....16:9 1456*2592...162:91 (建议者
3024*4992.......4:3
1936*2592...162:121
1536*2048.......4:3
480*640..........4:3
3024*5376.....16:9
1728*3072.....16:9
1456*2592...162:91
(建议者)
然而,我想要的是拍摄分辨率为800x600的图像,这真的有可能吗?只有在相机支持的情况下,才能使用800x600。例如,我的相机就没有 查找可用的解决方案:
uint[] x_res; // available horizontal resolutions
uint[] y_res; // available vertical resolutions
uint resolutionwidth; //used horizontal resolution
uint resolutionheight; //used vertical resolution
private void get_res_button_click(object sender, RoutedEventArgs e)
{
resolution_listbox.Items.Clear();
IEnumerable<VideoEncodingProperties> available_resolutions = captureManager.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo).Select(x => x as VideoEncodingProperties);
int total_res = available_resolutions.Count();
x_res = new uint[total_res];
y_res = new uint[total_res]
int i = 0;
foreach (VideoEncodingProperties resolution in available_resolutions)
{
x_res[i] = resolution.Width;
y_res[i] = resolution.Height;
resolution_listbox.Items.Add(x_res[i].ToString() + " x " + y_res[i].ToString());
i++;
}
}
uint[]x_res;//可用的水平分辨率
uint[]是的;是的可用垂直分辨率
单位分辨率宽度//使用的水平分辨率
单位分辨率高度//使用的垂直分辨率
私有void获取\u res\u按钮\u单击(对象发送者,路由目标)
{
解析_listbox.Items.Clear();
IEnumerable available_resolutions=captureManager.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo)。选择(x=>x作为视频编码属性);
int total_res=可用的分辨率。Count();
x_res=新单元[总分辨率];
y_res=新单元[总分辨率]
int i=0;
foreach(视频编码属性可用分辨率的分辨率)
{
x_res[i]=分辨率宽度;
y_res[i]=分辨率高度;
解析列表框.Items.Add(x_res[i].ToString()+“x”+y_res[i].ToString());
i++;
}
}
选择您想要的一个:
private async void resolution_listbox_selectionchanged(object sender, SelectionChangedEventArgs e)
{
if (resolution_listbox.SelectedItem != null)
{
int j = resolution_listbox.SelectedIndex;
resolutionwidth = x_res[j];
resolutionheight = y_res[j];
}
// And apply it:
IReadOnlyList<IMediaEncodingProperties> resolutions = captureManager.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo);
for (int k = 0; k < resolutions.Count; k++)
{
if (resolutions[k] is VideoEncodingProperties)
{
VideoEncodingProperties vidprops = (VideoEncodingProperties)resolutions[k];
// check which VideoEncodingProperties contains the correct resolution
if (vidprops.Width == resolutionwidth && vidprops.Height == resolutionheight)
{
await captureManager.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo, resolutions[k]);
}
}
}
}
private async void resolution\u listbox\u selectionchanged(对象发送方,selectionchangedventargs e)
{
如果(分辨率\u listbox.SelectedItem!=null)
{
int j=分辨率\u列表框。选择的索引;
分辨率宽度=x_res[j];
分辨率高度=y_res[j];
}
//并应用它:
IReadOnlyList resolutions=captureManager.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo);
for(int k=0;k
注意:在第一个方法中,我使用了IEnumerable在第二种方法中,我使用了IReadOnlyList