From 29e6e5e040de58fd43f90e82ed004b6eb34e5835 Mon Sep 17 00:00:00 2001 From: yixy-only Date: Wed, 17 Apr 2024 17:45:41 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E4=BF=AE=E5=A4=8D=E7=9A=84=E5=9C=A8=20i?= =?UTF-8?q?nigraph()=20=E4=B9=8B=E5=89=8D=E8=B0=83=E7=94=A8=20newimage()?= =?UTF-8?q?=20=20=E4=BC=9A=E5=BC=95=E8=B5=B7=E7=A8=8B=E5=BA=8F=E5=B4=A9?= =?UTF-8?q?=E6=BA=83=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原因: 在创建图像时创建了 GDI+ 对象但并未在此之前对 GDI+ 进行初始化 。#59 中引入(083423f) --- src/ege_graph.h | 3 +++ src/graphics.cpp | 11 +++++++++-- src/image.cpp | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ege_graph.h b/src/ege_graph.h index 44d11c08..c003378d 100644 --- a/src/ege_graph.h +++ b/src/ege_graph.h @@ -30,4 +30,7 @@ int waitdealmessage(_graph_setting* pg); float EGE_PRIVATE_GetFPS(int add); // 获取帧数 void setmode(int gdriver, int gmode); + +// GDI+ 初始化 +void gdipluinit(); } diff --git a/src/graphics.cpp b/src/graphics.cpp index 0432df9c..2e33b768 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -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 } } @@ -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 diff --git a/src/image.cpp b/src/image.cpp index 65a0400a..13698f4c 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -61,6 +61,7 @@ void IMAGE::construct(int width, int height) refDC = ::GetDC(graph_setting.hwnd); } + gdipluinit(); reset(); initimage(refDC, width, height); setdefaultattribute();