Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 修复在 inigraph() 之前调用 newimage() 会引起程序崩溃的问题 #153

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/ege_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ int waitdealmessage(_graph_setting* pg);
float EGE_PRIVATE_GetFPS(int add); // 获取帧数

void setmode(int gdriver, int gmode);

// GDI+ 初始化
void gdipluinit();
}
11 changes: 9 additions & 2 deletions src/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,7 @@ inline void init_img_page(struct _graph_setting* pg)
{
if (!pg->has_init) {
#ifdef EGE_GDIPLUS
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&pg->g_gdiplusToken, &gdiplusStartupInput, NULL);
gdipluinit();
#endif
}
}
Expand Down Expand Up @@ -1015,4 +1014,12 @@ long getGraphicsVer()
return EGE_VERSION_NUMBER;
}

void gdipluinit()
{
if (graph_setting.g_gdiplusToken == 0) {
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&graph_setting.g_gdiplusToken, &gdiplusStartupInput, NULL);
}
}

} // namespace ege
1 change: 1 addition & 0 deletions src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void IMAGE::construct(int width, int height)
refDC = ::GetDC(graph_setting.hwnd);
}

gdipluinit();
reset();
initimage(refDC, width, height);
setdefaultattribute();
Expand Down
Loading