Esempio n. 1
0
        /// <summary>
        /// Releases all allocated resources
        /// </summary>
        /// <param name="managed">True if called by user, false if called by finalizer</param>
        protected virtual void Dispose(bool managed)
        {
            if (!IsDisposed)
            {
                if (managed)
                {
                    InTransform  = null;
                    OutTransform = null;
                    VarsArray    = null;
                }

                _CAData?.Dispose();
                _InSpaceData?.Dispose();
                _OutSpaceData?.Dispose();
                _InICCData?.Dispose();
                _OutICCData?.Dispose();

                if (ColVars1Handle.IsAllocated)
                {
                    ColVars1Handle.Free();
                }
                if (ColVars2Handle.IsAllocated)
                {
                    ColVars2Handle.Free();
                }
                if (VarsHandle.IsAllocated)
                {
                    VarsHandle.Free();
                }
                if (InWPHandle.IsAllocated)
                {
                    InWPHandle.Free();
                }
                if (OutWPHandle.IsAllocated)
                {
                    OutWPHandle.Free();
                }
                if (InWPCrHandle.IsAllocated)
                {
                    InWPCrHandle.Free();
                }
                if (OutWPCrHandle.IsAllocated)
                {
                    OutWPCrHandle.Free();
                }
                if (CAMatrixHandle.IsAllocated)
                {
                    CAMatrixHandle.Free();
                }
                if (AdditionalDataPointer != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(AdditionalDataPointer);
                }
                if (AdditionalDataHandle != null)
                {
                    foreach (var data in AdditionalDataHandle)
                    {
                        data?.Dispose();
                    }
                }

                _IsDisposed = true;
            }
        }