Skip to content

Instantly share code, notes, and snippets.

@smourier
Created August 18, 2024 18:39
Show Gist options
  • Save smourier/ec63b4a74f1e125ec5ac5d22676b0cd2 to your computer and use it in GitHub Desktop.
Save smourier/ec63b4a74f1e125ec5ac5d22676b0cd2 to your computer and use it in GitHub Desktop.
Use WIC component with GDI+ (version 3)
var hr = GdiplusStartup(out var token, StartupInputEx.GetDefault(), out var output);
using var img = new Bitmap(Environment.GetCommandLineArgs()[1]);
[DllImport("gdiplus")]
private static extern int GdiplusStartup(out nint token, in StartupInputEx input, out StartupOutput output);
private struct StartupInputEx
{
public int GdiplusVersion;
public nint DebugEventCallback;
public bool SuppressBackgroundThread;
public bool SuppressExternalCodecs;
public int StartupParameters;
public static StartupInputEx GetDefault()
{
var result = new StartupInputEx
{
GdiplusVersion = 3
};
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment