Exemple #1
0
        /// <summary>
        /// Function to determine if the source format can convert to any of the formats in the destination list.
        /// </summary>
        /// <param name="sourceFormat">The source format to compare.</param>
        /// <param name="destFormat">List of destination formats to compare.</param>
        /// <returns>An array of formats that the source format can be converted into, or an empty array if no conversion is possible.</returns>
        public static IReadOnlyList <BufferFormat> CanConvertToAny(this BufferFormat sourceFormat, IEnumerable <BufferFormat> destFormat)
        {
            if ((sourceFormat == BufferFormat.Unknown) ||
                (destFormat == null))
            {
                return(Array.Empty <BufferFormat>());
            }

            if (destFormat.All(item => item == sourceFormat))
            {
                return(destFormat.ToArray());
            }

            using (var wic = new WicUtilities())
            {
                return(wic.CanConvertFormats(sourceFormat, destFormat));
            }
        }