/binding/win32/gdiplusinit.d
D | 144 lines | 65 code | 25 blank | 54 comment | 0 complexity | a12c6427a696c5d8794a47f290072006 MD5 | raw file
1/* 2 * gdiplusinit.d 3 * 4 * This module binds GdiPlusInit.h to D. The original copyright 5 * notice is preserved below. 6 * 7 * Author: Dave Wilkinson 8 * Originated: November 25th, 2009 9 * 10 */ 11 12module binding.win32.gdiplusinit; 13 14import binding.win32.windef; 15import binding.win32.winbase; 16import binding.win32.winnt; 17 18import binding.win32.gdiplustypes; 19 20extern(System): 21 22/************************************************************************** 23* 24* Copyright (c) 2000-2003 Microsoft Corporation 25* 26* Module Name: 27* 28* Gdiplus initialization 29* 30* Abstract: 31* 32* GDI+ Startup and Shutdown APIs 33* 34**************************************************************************/ 35 36enum DebugEventLevel { 37 DebugEventLevelFatal, 38 DebugEventLevelWarning 39} 40 41// Callback function that GDI+ can call, on debug builds, for assertions 42// and warnings. 43 44alias VOID function(DebugEventLevel level, CHAR* message) DebugEventProc; 45 46// Notification functions which the user must call appropriately if 47// "SuppressBackgroundThread" (below) is set. 48 49alias Status function(ULONG_PTR* token) NotificationHookProc; 50alias VOID function(ULONG_PTR token) NotificationUnhookProc; 51 52// Input structure for GdiplusStartup() 53 54struct GdiplusStartupInput { 55 UINT32 GdiplusVersion = 1; // Must be 1 (or 2 for the Ex version) 56 DebugEventProc DebugEventCallback = null; // Ignored on free builds 57 BOOL SuppressBackgroundThread = FALSE; // FALSE unless you're prepared to call 58 // the hook/unhook functions properly 59 BOOL SuppressExternalCodecs = FALSE; // FALSE unless you want GDI+ only to use 60 // its internal image codecs. 61 62 GdiplusStartupInput init( 63 DebugEventProc debugEventCallback = null, 64 BOOL suppressBackgroundThread = FALSE, 65 BOOL suppressExternalCodecs = FALSE) { 66 67 GdiplusStartupInput ret; 68 ret.GdiplusVersion = 1; 69 ret.DebugEventCallback = debugEventCallback; 70 ret.SuppressBackgroundThread = suppressBackgroundThread; 71 ret.SuppressExternalCodecs = suppressExternalCodecs; 72 return ret; 73 } 74} 75 76struct GdiplusStartupInputEx { 77 UINT32 GdiplusVersion = 2; // Must be 1 (or 2 for the Ex version) 78 DebugEventProc DebugEventCallback = null; // Ignored on free builds 79 BOOL SuppressBackgroundThread = FALSE; // FALSE unless you're prepared to call 80 // the hook/unhook functions properly 81 BOOL SuppressExternalCodecs = FALSE; // FALSE unless you want GDI+ only to use 82 // its internal image codecs. 83 INT StartupParameters = 0; // Do we not set the FPU rounding mode 84 85 GdiplusStartupInputEx init( 86 INT startupParameters = 0, 87 DebugEventProc debugEventCallback = null, 88 BOOL suppressBackgroundThread = FALSE, 89 BOOL suppressExternalCodecs = FALSE) { 90 91 GdiplusStartupInputEx ret; 92 ret.GdiplusVersion = 2; 93 ret.DebugEventCallback = debugEventCallback; 94 ret.SuppressBackgroundThread = suppressBackgroundThread; 95 ret.SuppressExternalCodecs = suppressExternalCodecs; 96 ret.StartupParameters = startupParameters; 97 return ret; 98 } 99} 100 101enum GdiplusStartupParams { 102 GdiplusStartupDefault = 0, 103 GdiplusStartupNoSetRound = 1, 104 GdiplusStartupSetPSValue = 2, 105 GdiplusStartupTransparencyMask = 0xFF000000 106} 107 108// Output structure for GdiplusStartup() 109 110struct GdiplusStartupOutput { 111 // The following 2 fields are NULL if SuppressBackgroundThread is FALSE. 112 // Otherwise, they are functions which must be called appropriately to 113 // replace the background thread. 114 // 115 // These should be called on the application's main message loop - i.e. 116 // a message loop which is active for the lifetime of GDI+. 117 // "NotificationHook" should be called before starting the loop, 118 // and "NotificationUnhook" should be called after the loop ends. 119 120 NotificationHookProc NotificationHook; 121 NotificationUnhookProc NotificationUnhook; 122} 123 124// GDI+ initialization. Must not be called from DllMain - can cause deadlock. 125// 126// Must be called before GDI+ API's or constructors are used. 127// 128// token - may not be NULL - accepts a token to be passed in the corresponding 129// GdiplusShutdown call. 130// input - may not be NULL 131// output - may be NULL only if input->SuppressBackgroundThread is FALSE. 132 133Status GdiplusStartup( 134 ULONG_PTR *token, 135 GdiplusStartupInput *input, 136 GdiplusStartupOutput *output); 137 138// GDI+ termination. Must be called before GDI+ is unloaded. 139// Must not be called from DllMain - can cause deadlock. 140// 141// GDI+ API's may not be called after GdiplusShutdown. Pay careful attention 142// to GDI+ object destructors. 143 144VOID GdiplusShutdown(ULONG_PTR token);