public EncoderParameters GetEncoderParameterList(Guid encoder) { EncoderParameters parameters; int num; int status = SafeNativeMethods.Gdip.GdipGetEncoderParameterListSize(new HandleRef(this, this.nativeImage), ref encoder, out num); if (status != 0) { throw SafeNativeMethods.Gdip.StatusException(status); } if (num <= 0) { return(null); } IntPtr buffer = Marshal.AllocHGlobal(num); status = SafeNativeMethods.Gdip.GdipGetEncoderParameterList(new HandleRef(this, this.nativeImage), ref encoder, num, buffer); try { if (status != 0) { throw SafeNativeMethods.Gdip.StatusException(status); } parameters = EncoderParameters.ConvertFromMemory(buffer); } finally { Marshal.FreeHGlobal(buffer); } return(parameters); }
/// <summary> /// Returns information about the codecs used for this <see cref='Image'/>. /// </summary> public EncoderParameters GetEncoderParameterList(Guid encoder) { EncoderParameters p; Gdip.CheckStatus(Gdip.GdipGetEncoderParameterListSize( new HandleRef(this, nativeImage), ref encoder, out int size)); if (size <= 0) { return(null); } IntPtr buffer = Marshal.AllocHGlobal(size); try { Gdip.CheckStatus(Gdip.GdipGetEncoderParameterList( new HandleRef(this, nativeImage), ref encoder, size, buffer)); p = EncoderParameters.ConvertFromMemory(buffer); } finally { Marshal.FreeHGlobal(buffer); } return(p); }
/// <summary> /// Returns information about the codecs used for this <see cref='Image'/>. /// </summary> public EncoderParameters GetEncoderParameterList(Guid encoder) { EncoderParameters p; int size; int status = SafeNativeMethods.Gdip.GdipGetEncoderParameterListSize(new HandleRef(this, nativeImage), ref encoder, out size); if (status != SafeNativeMethods.Gdip.Ok) { throw SafeNativeMethods.Gdip.StatusException(status); } if (size <= 0) { return(null); } IntPtr buffer = Marshal.AllocHGlobal(size); try { status = SafeNativeMethods.Gdip.GdipGetEncoderParameterList(new HandleRef(this, nativeImage), ref encoder, size, buffer); if (status != SafeNativeMethods.Gdip.Ok) { throw SafeNativeMethods.Gdip.StatusException(status); } p = EncoderParameters.ConvertFromMemory(buffer); } finally { Marshal.FreeHGlobal(buffer); } return(p); }
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.ConvertFromMemory(rawEPList); GDIPlus.CheckStatus(status); } finally { Marshal.FreeHGlobal(rawEPList); } return(eps); }