// Pix destruction /// <summary> /// (1) Decrements the ref count and, if 0, destroys the pix. /// (2) Always nulls the input ptr. /// </summary> /// <param name="ppix"></param> public static void pixDestroy(this Pix ppix) { if (null == ppix) { throw new ArgumentNullException("ppix cannot be null"); } var pointer = (IntPtr)ppix; // If the refcount is 1 we're about to destroy it // If it's greater than 1 then we're just going to decrement the refcount if (ppix.RefCount == 1) { // Free the additional items Darren added ppix?.Bitmap?.Dispose(); //if (ppix.Colormap != null) // ppix.Colormap.pixcmapDestroy(); ppix?.pixFreeData(); } Native.DllImports.pixDestroy(ref pointer); ppix = null; }