CSharpImageLibrary.WIC_Codecs.WindowsCodecsPresent C# (CSharp) Method

WindowsCodecsPresent() static private method

Tests whether Windows WIC Codecs are present.
static private WindowsCodecsPresent ( ) : bool
return bool
        internal static bool WindowsCodecsPresent()
        {
            byte[] testData = Resources.DXT1_CodecTest;  // KFreon: Tiny test image in resources

            try
            {
                BitmapImage bmp = AttemptUsingWindowsCodecs(testData, 0, 0);
                bmp.Freeze();
                if (bmp == null)
                {
                    ImageEngine.WindowsWICCodecsAvailable = false;
                    return false;  // KFreon: Decoding failed. PROBABLY due to no decoding available
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
                ImageEngine.WindowsWICCodecsAvailable = false;
                return false;  // KFreon: Non decoding related error - Who knows...
            }

            return true;
        }

Usage Example

        /// <summary>
        /// Constructor. Checks WIC status before any other operation.
        /// </summary>
        static ImageEngine()
        {
            var path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            ProfileOptimization.SetProfileRoot(path);
            ProfileOptimization.StartProfile("Startup.Profile_ImageEngine");

            WindowsWICCodecsAvailable = WIC_Codecs.WindowsCodecsPresent();

            // Set NumThreads to be more sensible
            NumThreads = Environment.ProcessorCount - 1;
            if (NumThreads == 0) // Single core...
            {
                NumThreads = 1;
            }


            // Enable GPU Acceleration by default

            /*if (GPU.IsGPUAvailable)
             *  EnableGPUAcceleration = false;*/
        }
All Usage Examples Of CSharpImageLibrary.WIC_Codecs::WindowsCodecsPresent