-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgdiplusinit.py
More file actions
137 lines (115 loc) · 5.17 KB
/
Copy pathgdiplusinit.py
File metadata and controls
137 lines (115 loc) · 5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
"""
/**************************************************************************
*
* Copyright (c) 2000-2003 Microsoft Corporation
*
* Module Name:
*
* Gdiplus initialization
*
* Abstract:
*
* GDI+ Startup and Shutdown APIs
*
**************************************************************************/
"""
from . import cpreproc
from .minwindef import *
from .defbase import *
if cpreproc.pragma_once("_GDIPLUSINIT_H"):
from .gdiplustypes import Status
gdiplus = W_WinDLL("gdiplus.dll")
# REGION *** Desktop Family ***
DebugEventLevel = INT
if True:
DebugEventLevelFatal = 0
DebugEventLevelWarning = 1
# Callback function that GDI+ can call, on debug builds, for assertions
# and warnings.
DebugEventProc = WINAPI(VOID, DebugEventLevel, PCHAR)
# Notification functions which the user must call appropriately if
# "SuppressBackgroundThread" (below) is set.
NotificationHookProc = WINAPI(Status, PULONG_PTR)
NotificationUnhookProc = WINAPI(VOID, ULONG_PTR)
# Input structure for GdiplusStartup()
class GdiplusStartupInput(CStructure):
_pack_ = 8
_fields_ = [
("GdiplusVersion", UINT32), # Must be 1 (or 2 for the Ex version)
("DebugEventCallback", DebugEventProc), # Ignored on free builds
("SuppressBackgroundThread", BOOL), # FALSE unless you're prepared to call
# the hook/unhook functions properly
("SuppressExternalCodecs", BOOL) # FALSE unless you want GDI+ only to use
# its internal image codecs.
]
def __init__(self,
debugEventCallback = cast(NULL, DebugEventProc),
suppressBackgroundThread = False,
suppressExternalCodecs = False):
self.GdiplusVersion = 1
self.DebugEventCallback = debugEventCallback
self.SuppressBackgroundThread = suppressBackgroundThread
self.SuppressExternalCodecs = suppressExternalCodecs
#if (GDIPVER >= 0x0110)
class GdiplusStartupInputEx(CStructure):
_pack_ = 8
_fields_ = [
("GdiplusVersion", UINT32), # Must be 1 (or 2 for the Ex version)
("DebugEventCallback", DebugEventProc), # Ignored on free builds
("SuppressBackgroundThread", BOOL), # FALSE unless you're prepared to call
# the hook/unhook functions properly
("SuppressExternalCodecs", BOOL), # FALSE unless you want GDI+ only to use
# its internal image codecs.
("StartupParameters", INT) # Do we not set the FPU rounding mode
]
def __init__(self,
startupParameters = 0,
debugEventCallback = cast(NULL, DebugEventProc),
suppressBackgroundThread = False,
suppressExternalCodecs = False):
self.GdiplusVersion = 2
self.DebugEventCallback = debugEventCallback
self.SuppressBackgroundThread = suppressBackgroundThread
self.SuppressExternalCodecs = suppressExternalCodecs
self.StartupParameters = startupParameters
GdiplusStartupParams = INT
if True:
GdiplusStartupDefault = 0
GdiplusStartupNoSetRound = 1
GdiplusStartupSetPSValue = 2
GdiplusStartupTransparencyMask = 0xFF000000
# Output structure for GdiplusStartup()
class GdiplusStartupOutput(CStructure):
_pack_ = 8
_fields_ = [
# The following 2 fields are NULL if SuppressBackgroundThread is FALSE.
# Otherwise, they are functions which must be called appropriately to
# replace the background thread.
#
# These should be called on the application's main message loop - i.e.
# a message loop which is active for the lifetime of GDI+.
# "NotificationHook" should be called before starting the loop,
# and "NotificationUnhook" should be called after the loop ends.
("NotificationHook", NotificationHookProc),
("NotificationUnhook", NotificationUnhookProc)
]
"""
// GDI+ initialization. Must not be called from DllMain - can cause deadlock.
//
// Must be called before GDI+ API's or constructors are used.
//
// token - may not be NULL - accepts a token to be passed in the corresponding
// GdiplusShutdown call.
// input - may not be NULL
// output - may be NULL only if input->SuppressBackgroundThread is FALSE.
"""
GdiplusStartup = declare(gdiplus.GdiplusStartup, Status, PULONG_PTR, POINTER(GdiplusStartupInput), POINTER(GdiplusStartupOutput))
"""
// GDI+ termination. Must be called before GDI+ is unloaded.
// Must not be called from DllMain - can cause deadlock.
//
// GDI+ API's may not be called after GdiplusShutdown. Pay careful attention
// to GDI+ object destructors.
"""
GdiplusShutdown = declare(gdiplus.GdiplusShutdown, VOID, ULONG_PTR)
# REGION ***