예제 #1
0
 static FreeImageEngine()
 {
     // Check if FreeImage.dll is present and cancel setting the callback function if not
     if (!IsAvailable)
     {
         return;
     }
     // Create a delegate (function pointer) to 'OnMessage'
     outputMessageFunction = new OutputMessageFunction(OnMessage);
     // Set the callback
     FreeImage.SetOutputMessage(outputMessageFunction);
 }
        private static void InitializeMessage()
        {
            if (null == outputMessageFunction)
            {
                lock (outputMessageFunctionLock)
                {
                    if (null == outputMessageFunction)
                    {
                        FreeImage.ValidateAvailability();

                        try
                        {
                            // Create a delegate (function pointer) to 'OnMessage'
                            outputMessageFunction =
                                delegate(FREE_IMAGE_FORMAT fif, string message)
                            {
                                LastErrorMessage = message;

                                // Get a local copy of the multicast-delegate
                                OutputMessageFunction m = FreeImageEngine.message;

                                // Check the local copy instead of the static instance
                                // to prevent a second thread from setting the delegate
                                // to null, which would cause a nullreference exception
                                if (m != null)
                                {
                                    // Invoke the multicast-delegate
                                    m.Invoke(fif, message);
                                }
                            };

                            // Set the callback
                            FreeImage.SetOutputMessage(outputMessageFunction);
                        }
                        catch
                        {
                            outputMessageFunction = null;
                            throw;
                        }
                    }
                }
            }
        }
예제 #3
0
 static FreeImageAlgorithmsBitmap()
 {
     FreeImage.SetOutputMessage(errorCallback);
 }