private void InitializeResolutionSettings()

in Tools/Cam360/MainPage.xaml.cs [536:582]


        private void InitializeResolutionSettings()
        {
            cmbResolution.Items.Clear();
            _filteredSourceFormat = new List<MediaFrameFormat>();
            //retrieve all supported formats
            List<MediaFrameFormat> supportedFormats = _selectedFrameSource.SupportedFormats.ToList();
            uint maxResolution = 0;
            int maxResolutionPropertyIndex = 0;
            int supportedFormatIndex = 0;

            // filter out and skip mjpeg and rgb24 video formats
            foreach(MediaFrameFormat format in supportedFormats)
            {
                VideoMediaFrameFormat videoFormat = format.VideoFormat;
                string subtype = format.Subtype.ToLowerInvariant();
                if (subtype == MediaEncodingSubtypes.Mjpg.ToLowerInvariant()
                    || (format.FrameRate.Denominator <=0 ) //workaround for some bad camera f/w
                    )
                {
                    continue;
                }

                uint resolution = videoFormat.Width * videoFormat.Height;
                if (resolution > maxResolution)
                {
                    maxResolution = resolution;
                    maxResolutionPropertyIndex = supportedFormatIndex;
                }

                Debug.WriteLine("Resolution of : {0} x {1}", videoFormat.Width, videoFormat.Height);
                Debug.WriteLine("Type: {0} and subtype: {1}", format.MajorType, format.Subtype);

                string aspectRatio = GetAspectRatio(videoFormat.Width, videoFormat.Height);
                cmbResolution.Items.Add(string.Format("{0}, {1}, {2}MP, {3}x{4}@{5}fps",
                    format.Subtype, 
                    aspectRatio, 
                    ((float)((videoFormat.Width * videoFormat.Height) / 1000000.0)).ToString("0.00"), 
                    videoFormat.Width, videoFormat.Height,
                    format.FrameRate.Numerator/format.FrameRate.Denominator));

                _filteredSourceFormat.Add(format);
                supportedFormatIndex++;
            }

            // Select maximum resolution available
            cmbResolution.SelectedIndex = maxResolutionPropertyIndex;
        }