Esempio n. 1
0
        /// <summary>
        /// Frees a bitmap previously allocated with AllocateBitmap.
        /// </summary>
        /// <param name="handle">The handle that was returned from a previous call to AllocateBitmap.</param>
        /// <param name="width">The width of the bitmap, as specified in the original call to AllocateBitmap.</param>
        /// <param name="height">The height of the bitmap, as specified in the original call to AllocateBitmap.</param>
        public static void FreeBitmap(IntPtr handle, int width, int height)
        {
            long bytes = (long)width * (long)height * 4;

            bool bResult = SafeNativeMethods.DeleteObject(handle);

            if (!bResult)
            {
                NativeMethods.ThrowOnWin32Error("DeleteObject returned false");
            }

            if (bytes > 0)
            {
                GC.RemoveMemoryPressure(bytes);
            }
        }