天天看点

[游戏模版7] Win32 最简单贴图

>_<:this is the first using mapping.

>_<:There will be introducing how to do:

First load bitmap picture return handle give hbmp, as

following:

hbmp=(HBITMAP)LoadImage(NULL,"bg.bmp",IMAGE_BITMAP,600,450,LR_LOADFROMFILE);

there "bg.bmp" must put in the

project folder!

Second if you want

draw this picture in the window,I suggest you should create a CompatibleDC,

maybe now you don‘t know why do this, the reason is also hard to explane. You

just remember doing is better for showing many pictures reducing

Flash.

hdc=GetDC(hWnd);

mdc=CreateCompatibleDC(hdc);

Third when you finish upper two steps, you can use SelectObject(mdc,hbmp); give

the picture to CompatibleDC mdc

Finally just use BitBlt(hdc,0,0,600,450,mdc,0,0,SRCCOPY); copy mdc including to hdc to show in the

window.

[游戏模版7] Win32 最简单贴图
[游戏模版7] Win32 最简单贴图
[游戏模版7] Win32 最简单贴图

resourse.h

[游戏模版7] Win32 最简单贴图

StdAfx.h

main.cpp