Exemplo n.º 1
0
            public void Dispose()
            {
                if (allocated)
                {
                    IntPtr[] infPtrs = new IntPtr[1];
                    IntPtr   mem;

                    // alloc unmanaged memory
                    mem        = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Win32.AVICOMPRESSOPTIONS)));
                    infPtrs[0] = mem;

                    // copy from managed structure to unmanaged memory
                    Marshal.StructureToPtr(comprOptions, mem, false);

                    Win32.AVISaveOptionsFree(1, infPtrs);
                    Marshal.FreeHGlobal(mem);

                    codec        = null;
                    comprOptions = new Win32.AVICOMPRESSOPTIONS();
                    allocated    = false;
                }
                if (marshaled)
                {
                    IntPtr p;
                    p = (IntPtr)comprOptions.lpFormat;
                    if (p != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(p);
                    }
                    p = (IntPtr)comprOptions.lpParms;
                    if (p != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(p);
                    }

                    codec        = null;
                    comprOptions = new Win32.AVICOMPRESSOPTIONS();
                    marshaled    = false;
                }
            }