void LoadImgFromGDIP(){
GdiplusStartup GDIPStart = (GdiplusStartup)GetProcAddress(LoadLibrary(TEXT("gdiplus.dll")), "GdiplusStartup");
GdipCreateFromHDC GDIPCreate = (GdipCreateFromHDC)GetProcAddress(LoadLibrary(TEXT("gdiplus.dll")), "GdipCreateFromHDC");
GdipLoadImageFromFile GDIPLoadImgFile = (GdipLoadImageFromFile)GetProcAddress(LoadLibrary(TEXT("gdiplus.dll")), "GdipLoadImageFromFile");
GdipDrawImageRect GDIPDrawImgRect = (GdipDrawImageRect)GetProcAddress(LoadLibrary(TEXT("gdiplus.dll")), "GdipDrawImageRect");
GdipGetImageHeight GDIPGetImgHeight = (GdipGetImageHeight)GetProcAddress(LoadLibrary(TEXT("gdiplus.dll")), "GdipGetImageHeight");
GdipGetImageWidth GDIPGetImgWidth = (GdipGetImageWidth)GetProcAddress(LoadLibrary(TEXT("gdiplus.dll")), "GdipGetImageWidth");
GdipDrawImage GDIPDrawImg = (GdipDrawImage)GetProcAddress(LoadLibrary(TEXT("gdiplus.dll")), "GdipDrawImage");
PAINTSTRUCT ps;
HDC hdc;
HDC mDC;
int lngHeight, lngWidth;
int *img;
int *graphics;
GdiplusStartupInput Input;
Input.DebugEventCallback = NULL;
Input.GdiplusVersion = 1;
Input.SuppressBackgroundThread = 0;
Input.SuppressExternalCodecs = 0;
ULONG_PTR ulToken;
int iRet=0;
iRet = GDIPStart(&ulToken, &Input, NULL);
if (iRet != 0){
MB(TEXT("ERROR,StartUp"),1); }
hdc = BeginPaint(hPIC_LOGO, &ps); mDC = CreateCompatibleDC(hdc);
iRet = GDIPCreate(mDC, &graphics);
WCHAR szFilePath[256];
MultiByteToWideChar(CP_ACP, 0, TEXT("1.bmp"), -1, szFilePath, 256);
iRet = GDIPLoadImgFile(szFilePath, &img);
iRet = GDIPGetImgHeight(img, &lngHeight);
iRet = GDIPGetImgWidth(img, &lngWidth);
iRet = GDIPDrawImg(graphics, img, 0, 0);
if (iRet != 0){
MB(TEXT("ERROR,GDIPDrawImg"), 1); }
DeleteDC(mDC);
EndPaint(hPIC_LOGO, &ps);
}
I'm using plain C to call these functions of GDI+ ,and response WM_PAINT with this function ,the last call of GdipDrawImage returns 0, it means success ,but on my picture control I can not find my picture on it.