[游戏模版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 ...
随机推荐
- 使用 archetype插件创建maven目录结构
步骤一: 步骤二: 等待下载插件
- asp.net GridView控件中诗选全选和全不选功能
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- R6010 - abort() has been called 错误
今天修改了下程序,发布到服务器上进行测试,结果在测试的时候弹出下面的一个框: 找了N久,发现了原因,差点呗自己弄哭了.. 程序里写了下面这句代码,没有注释掉.
- [转][MSSQL]SQL Server 2008 记住密码功能
本文转自:http://zhidao.baidu.com/link?url=V_laNOvutMin0kU3DUaMhLSFAYfgtz2IoEAjh8grNVPOZLpd8Pudb4iqZl88Tn ...
- [html]选项卡效果
晨间新闻 午间新闻 晚间新闻 视频新闻 <!doctype html> <html> <head> <meta charset="UTF-8&quo ...
- JavaWeb---图书馆管理系统
写在开头,以后每天写记录. 今天,初步了解了一下,项目需求,用现在自己所学的知识,很多还不能做出来. 先用目前的知识,一步步的做出来,不断的完善,今天遇到的问题: 任务分析: 01.list页面的ad ...
- JavaScript密码复杂度
<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8" ...
- js 去掉字符串前后空格
//去左空格; function ltrim(s){ return s.replace(/(^\s*)/g, ""); } //去右空格; function rtrim(s){ r ...
- Oracle 索引<七>
Oracle 索引 管理索引-原理介绍 介绍 索引是用于加速数据存取的数据对象.合理的使用索引可以大大降低 i/o 次数,从而提高数据访问性能.索引有很多种我们主要介绍常用的几种: 为什么添加了索 ...
- oracle删除数据恢复
分为两种方法:scn和时间戳两种方法恢复. 一.通过scn恢复删除且已提交的数据 1.获得当前数据库的scn号 select current_scn from v$database; (切换到sys用 ...