[游戏模版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 ...
随机推荐
- jquery移动端日期插件
不说多的,直接看代码<!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...
- spark streaming 实战
最近在学习spark的相关知识, 重点在看spark streaming 和spark mllib相关的内容. 关于spark的配置: http://www.powerxing.com/spark-q ...
- 使用soureTree删除分支
使用心得 1:使用pull拉取时,自己本地的更改不会覆盖掉 2:删除分枝时,直接选中,可以直接删除远程的分枝
- iOS 设置button文字过长而显示省略号的解决办法
UIButton * button =[UIButton buttonWithType:UIButtonTypeCustom];button.titleLabel.adjustsFontSizeToF ...
- 我为什么选择使用Go语言?
谢孟军:EGO会员.GopherChina组织者.<Go Web编程>一书的作者,专注Golang技术架构.本文来自EGO会员群分享,入群方式见文末 在这里我主要想和大家分享一些Go和我个 ...
- eclipse 配置黑色主题
虽然以前也使用eclipse的黑色主题,但是配置起来稍微麻烦一点. 这里先声明,下面的方式适合最新版本的Eclipse Luna,旧的版本可以下载我提供的这个插件,并将其放在eclipse目录下的pl ...
- 使用并行的方法计算斐波那契数列 (Fibonacci)
更新:我的同事Terry告诉我有一种矩阵运算的方式计算斐波那契数列,更适于并行.他还提供了利用TBB的parallel_reduce模板计算斐波那契数列的代码(在TBB示例代码的基础上修改得来,比原始 ...
- Delphi inline编译器优化问题
function Test():Integer; inline; var P:Pointer; begin FreeMem(P); Result := AtomicIncrement(__gr); / ...
- linux 清理内存命令 查看内存命令
查看内存: 我们可以用free命令查看内存信息: free -g total used free shared buffers cachedMem: 15 15 0 0 ...
- perl 对源文件内容修改 方法整理
1, 利用Tie::File模块来直接对文件内容进行修改. #!/usr/bin/perl -w my $std="F160"; my $fast="FAST" ...