[游戏模版8] Win32 透明贴图
>_<:The same with previous introduction. In the InitInstance fanction make a little change:
>_<:Yes just add another picture "dra.bmp" and give the handle to dra.And then call function MyPaint(...)
hdc=GetDC(hWnd);
mdc=CreateCompatibleDC(hdc); bg=(HBITMAP)LoadImage(NULL,"bg.bmp",IMAGE_BITMAP,,,LR_LOADFROMFILE);
dra=(HBITMAP)LoadImage(NULL,"dra.bmp",IMAGE_BITMAP,,,LR_LOADFROMFILE);
//名、类型、大小、加载方式; MyPaint(hdc);
ReleaseDC(hWnd,hdc);
>_<:As following here is the MyPaint(...) function:
>_<:In this function :
- firstly, move the picture "bg.bmp" to CompatibleDC mdc by its handle bg.
- Then copy mdc to hdc. Until now there is no any change.
- And then move dra to mdc,latter using twice BitBlt.
Here we can see:the seventh line, only use mdc's lower part do an operation SRCAND; the eighth line,use another part of mdc do an operation SRCPAINT. (Why through the two steps can achieve transparency? It involves some knowledge of image science, here will not introduce. )
>_<!However,one thing must be reminded:the picture of dra.bmp must use following style form:
Yes,the part that you don't want to show must use the black background and this part will be done the operation late than another part.And another part includes that you want to show must be black, you don't want to show must be white!
>_<:MyPaint(...)
void MyPaint(HDC hdc)
{
SelectObject(mdc,bg);
BitBlt(hdc,,,,,mdc,,,SRCCOPY);//在窗口位置、大小、原图剪切位 SelectObject(mdc,dra);
BitBlt(hdc,,,,,mdc,,,SRCAND);
BitBlt(hdc,,,,,mdc,,,SRCPAINT);
}
[游戏模版8] Win32 透明贴图的更多相关文章
- [游戏模版13] Win32 透明贴图 主角移动
>_<:just add previous two ways to achieve this new result // stdafx.h : include file for stand ...
- [游戏模版10] Win32 平面地图贴图 正
>_<:picture resource >_<:If you master the ways of mapping picture,then this problem is ...
- [游戏模版7] Win32 最简单贴图
>_<:this is the first using mapping. >_<:There will be introducing how to do: First load ...
- [游戏模版2] Win32最小框架
>_<:Just the minimum Win32 frame don't have any other special function. //{{NO_DEPENDENCIES}} ...
- [游戏模版12] Win32 稳定定时
>_<:The last time,we learned how to use timer to make the picture run and change show,but some ...
- [游戏模版14] Win32 键盘控制
>_<:compared with the previous article,this one only adds key-message listener. >_<:up d ...
- [游戏模版15] Win32 飞机射击
>_<:Only give you the code,try to understand it! >_<:picture resource #include <windo ...
- [游戏模版16] Win32 飞机射击 敌人追踪
>_<:AI introduction. >_<:According the plane position (nowX,nowY) relative to birds' pos ...
- [游戏模版17] Win32 推箱子 迷宫
>_<:Here introduce a simple game: >_<:resource >_<:only can push a box and finally ...
随机推荐
- JavaWEB域对象
PageContext: ServletRequest: HttpSession: ServletContext: void setAttribute(String name, Object valu ...
- javascript 命令方式 测试例子
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- C语课设心得分享(三)
调试. 以前咱们写课后习题,一般也不需要使用调试,如果程序编译error,根据错误信息就可以改好:如果是结果错误,那么在稿纸上过几遍基本也可以得出结果. 但咱们这个课设比较大,就需要很多调试的过程,尤 ...
- mysql 数据库导入 导出,解决 导入 错误问题
mysqldump -uxxxx -pxxxx -hrds2383jse53pi6ipwmf.mysql.rds.aliyuncs.com legaokao > /root/legaokaodu ...
- to_char 详解
对TO_CHAR的讨论可以分为从两种类型的数据到字符的转换:DATE和NUMBER. TO_CHAR函数返回VARCHAR2数据类型的值. 1. NUMBER TO CHAR 语法: TO_CHAR( ...
- mysql 命令行参数
MySQL命令行参数 Usage: mysql [OPTIONS] [database] //命令方式 例如: mysql -h${HOSTNAME} -P${PORT} -u${USERNAM ...
- android开发学习---layout布局、显示单位和如何进行单元测试
一.五大布局(layout) android中的用五大布局:LinearLayout (线性布局).AbsoluteLayout(绝对布局).RelativeLayout(相对布局).TableLay ...
- SQL Server 扩展一个支持类似。net 时间格式化的标量函数~
* FROM sys.objects WHERE name=N'uF_DateFormat' AND [type]='FN') DROP FUNCTION uF_DateFormat GO SET A ...
- python 中 深拷贝和浅拷贝的理解
在总结 python 对象和引用的时候,想到其实 对于python的深拷贝和浅拷贝也可以很好对其的进行理解. 在python中,对象的赋值的其实就是对象的引用.也就是说,当创建一个对象,然后赋给另外一 ...
- PoEdu - C++阶段班- Lesson02_C to C++
1 原生bool类型 c++里面的bool类型才是真正原生的true和faul,比如常见的大写的"BOOL",它就不是原生的. 原生的与非原生的bool,它们的区别: 详细说下原 ...