[游戏模版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 ...
随机推荐
- 【POJ3237】Tree(树链剖分)
题意:在一棵N个节点,有边权的树上维护以下操作: 1:单边修改,将第X条边的边权修改成Y 2:区间取反,将点X与Y在树上路径中的所有边边权取反 3:区间询问最大值,询问X到Y树上路径中边权最大值 n& ...
- crontab这个坑,执行单个命令执行成功,但是写到crontab怎么也不行
昨天开始,一直在弄通过定时任务控制熄屏,在终端下的单个命令可以执行成功,写到脚本里,单个执行脚本能成功,但是写到crontab定时任务,怎么也不熄屏,但他确实执行了,看日志,是一直报错的:百度了很多很 ...
- HTML5和CSS3基础教程(第8版)-读书笔记(3)
第11章 用CSS 进行布局 网站设计主要有两大类型:固定宽度和响应式. 对于固定(fixed)布局,整个页面和每一栏都有基于像素的宽度.顾名思义,无论是使用移动电话和平板电脑等较小的设备查看页面,还 ...
- 使用Intellij idea开发
使用IntelliJ IDEA开发SpringMVC网站(一)开发环境 使用IntelliJ IDEA开发SpringMVC网站(二)框架配置 使用IntelliJ IDEA开发SpringMVC网站 ...
- UzysAssetsPickerController中文化
self.labelSelectedMedia.text = NSLocalizedStringFromTable(@"Choose a media", @"UzysAs ...
- mvc深入理解
对于v和c好理解, 对于model分为数据对象模型和业务逻辑模型,一般为一个类,数据对象模型包含对一个具体数据表的相关操作,业务逻辑模型为处理一些业务逻辑.
- Training Deep Neural Networks
http://handong1587.github.io/deep_learning/2015/10/09/training-dnn.html //转载于 Training Deep Neural ...
- Adding AirDrop File Sharing Feature to Your iOS Apps
http://www.appcoda.com/ios7-airdrop-programming-tutorial/ Adding AirDrop File Sharing Feature to You ...
- 解Tom大叔出的Javascript题目
原文参考,http://www.cnblogs.com/TomXu/archive/2012/02/10/2342098.html Tom大叔的博客深入理解Javascript系列真是我们学习Java ...
- css3之边框新属性
border属性 属性 描述 border-image 图片边框 border-radius 圆角 box-shadow 矩形阴影