>_<: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 透明贴图的更多相关文章

  1. [游戏模版13] Win32 透明贴图 主角移动

    >_<:just add previous two ways to achieve this new result // stdafx.h : include file for stand ...

  2. [游戏模版10] Win32 平面地图贴图 正

    >_<:picture resource >_<:If you master the ways of mapping picture,then this problem is ...

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

    >_<:this is the first using mapping. >_<:There will be introducing how to do: First load ...

  4. [游戏模版2] Win32最小框架

    >_<:Just the minimum Win32  frame don't have any other special function. //{{NO_DEPENDENCIES}} ...

  5. [游戏模版12] Win32 稳定定时

    >_<:The last time,we learned how to use timer to make the picture run and change show,but some ...

  6. [游戏模版14] Win32 键盘控制

    >_<:compared with the previous article,this one only adds key-message listener. >_<:up d ...

  7. [游戏模版15] Win32 飞机射击

    >_<:Only give you the code,try to understand it! >_<:picture resource #include <windo ...

  8. [游戏模版16] Win32 飞机射击 敌人追踪

    >_<:AI introduction. >_<:According the plane position (nowX,nowY) relative to birds' pos ...

  9. [游戏模版17] Win32 推箱子 迷宫

    >_<:Here introduce a simple game: >_<:resource >_<:only can push a box and finally ...

随机推荐

  1. js 和 c# 方法互调

    js访问c#代码 1  js <script type="javascript"><%=test()%></script> c#  public ...

  2. nodejs--偏函数

    偏函数的例子,解释--假设有一个参数或变量已经预置的函数A,我们通过调用A来产生一个新的函数B,函数B就是我们说的偏函数 偏函数解决这样的问题:如果我们有函数是多个参数的,我们希望能固定其中某几个参数 ...

  3. HttpModule的一些初步认识

    新建一个类 ValidaterHttpModuleEvents继承管道接口 IHttpModule,代码如下 public class ValidaterHttpModuleEvents:IHttpM ...

  4. u3d shader forge 冰渐冻材质

    <ignore_js_op> 分享个自己研究的冰材质渐冻shader可以调节的参数很多,并且带模型顶点偏移,能更加真实模拟冰的凹凸厚度感.(参数过大容易出现模型破损,慎用)shader f ...

  5. 第七章 springboot + retrofit

    retrofit:一套RESTful架构的Android(Java)客户端实现. 好处: 基于注解 提供JSON to POJO,POJO to JSON,网络请求(POST,GET,PUT,DELE ...

  6. VS2005 “无法在证书存储区中找到清单签名证书”错误的解决方法

    方法一:在VS2005中出现该错误时,用记事本打开项目的.csproj文件,删除以下内容即可:    <ManifestCertificateThumbprint>B531F2CF2227 ...

  7. 常用linux指令

    删除:rm -rf -r 就是向下递归,不管有多少级目录,一并删除       -f 就是直接强行删除,不作任何提示的意思 压缩解压:tar -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向 ...

  8. Ubuntu和Windows的交互工具---Samba环境配置

    Samba软件安装 使用源代码安装samba,在终端输入如下指令: #sudo apt-get install samba #sudo apt-get install smbclient #sudo ...

  9. Java复数的四则运算

    import java.util.Scanner;   import com.sun.jndi.url.iiopname.iiopnameURLContextFactory;   public cla ...

  10. 张小龙《微信背后的产品观》之PPT完整文字版

    微信回顾 433天,一亿用户 成为移动互联网的新入口 启动(2010年11月19日) 用户数突破1亿 1.0 1月26日 2.0 5月10日 语音对讲 2.5 8月3日 查看那附近的人 3.0 10月 ...