public EncoderParameters GetEncoderParameterList(Guid encoder) { Status status; uint sz; status = GDIPlus.GdipGetEncoderParameterListSize(nativeObject, ref encoder, out sz); GDIPlus.CheckStatus(status); IntPtr rawEPList = Marshal.AllocHGlobal((int)sz); EncoderParameters eps; try { status = GDIPlus.GdipGetEncoderParameterList(nativeObject, ref encoder, sz, rawEPList); eps = EncoderParameters.FromNativePtr(rawEPList); GDIPlus.CheckStatus(status); } finally { Marshal.FreeHGlobal(rawEPList); } return(eps); }