A small example :
.if uMsg == WM_CREATE
mov rax,OFFSET StartupInfo
mov GdiplusStartupInput.GdiplusVersion[rax],1
invoke GdiplusStartup,ADDR token,ADDR StartupInfo,0
invoke UnicodeStr,ADDR filename,ADDR UnicodeFileName
invoke GdipCreateBitmapFromFile,ADDR UnicodeFileName,\
ADDR BmpImage
invoke GdipCreateHBITMAPFromBitmap,BmpImage,\
ADDR hBitmap+rip,0
invoke GdipDisposeImage,BmpImage
.elseif uMsg == WM_PAINT
invoke BeginPaint,_hWnd,ADDR ps
mov hdc,rax
invoke CreateCompatibleDC,rax
mov hMemDC,rax
invoke SelectObject,rax,hBitmap+rip
invoke GetObject,hBitmap+rip,sizeof(BITMAP),ADDR bm
lea r11,bm
mov r10d,BITMAP.bmHeight[r11]
mov r9d,BITMAP.bmWidth[r11]
invoke BitBlt,hdc,0,0,r9,r10,\
hMemDC,0,0,SRCCOPY
invoke DeleteDC,hMemDC
invoke EndPaint,_hWnd,ADDR ps
Using GDI+ functions to retrieve the height and width of an image :
.if uMsg == WM_CREATE
mov rax,OFFSET StartupInfo
mov GdiplusStartupInput.GdiplusVersion[rax],1
invoke GdiplusStartup,ADDR token,ADDR StartupInfo,0
invoke UnicodeStr,ADDR filename,ADDR UnicodeFileName
invoke GdipCreateBitmapFromFile,ADDR UnicodeFileName,\
ADDR BmpImage
invoke GdipGetImageWidth,BmpImage,ADDR ImgWidth+rip
invoke GdipGetImageHeight,BmpImage,ADDR ImgHeight+rip
invoke GdipCreateHBITMAPFromBitmap,BmpImage,\
ADDR hBitmap+rip,0
invoke GdipDisposeImage,BmpImage
invoke GdiplusShutdown,token
.elseif uMsg == WM_PAINT
invoke BeginPaint,_hWnd,ADDR ps
mov hdc,rax
invoke CreateCompatibleDC,rax
mov hMemDC,rax
invoke SelectObject,rax,hBitmap+rip
invoke BitBlt,hdc,0,0,\
ImgWidth+rip,ImgHeight+rip,\
hMemDC,0,0,SRCCOPY
invoke DeleteDC,hMemDC
invoke EndPaint,_hWnd,ADDR ps
GdiPlusFlat is capable to paint picture without bitmap.
Perhaps in a your further example is coming ?
Hi Timo,
About creating a picture without a bitmap, could you provide some detailş?
GdiPlus have some functions for displaying image:
GpGraphics *g;
GdipCreateFromHDC(hDC, &g);
GdipDrawImage(g, img, 0.0, 0.0);
//GdipDrawImageRect(g, img, 0.0, 0.0, 100.0, 100.0);
GdipDeleteGraphics(g);
Naturally painting a bitmap might be faster.
Hi Timo,
Thanks for the heads-up. Here is a GdipDrawLine example.