>_<: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. VC++ 中简单操作MP3音乐的方法,小结

    #include <windows.h> #include <stdio.h> #include <mmsystem.h> #include <shellap ...

  2. GBDT(MART) 迭代决策树入门教程 | 简介

    GBDT(MART) 迭代决策树入门教程 | 简介  http://blog.csdn.net/w28971023/article/details/8240756

  3. iOS相关思考题

    1.iOS如何应对APP版本升级,数据结构随之变化? 一般程序app升级时,数据库有可能发生改变,如增加表字段,增加表等. 此时有两种操作: 1 就是毫无留情的把本地旧数据库直接删掉,重新建立新的数据 ...

  4. 【BZOJ2595】游览计划(状压DP,斯坦纳树)

    题意:见题面(我发现自己真是越来越懒了) 有N*M的矩阵,每个格子有一个值a[i,j] 现要求将其中的K个点(称为关键点)用格子连接起来,取(i,j)的费用就是a[i,j] 求K点全部连通的最小花费以 ...

  5. 让阿里云支持ipv6(其他多数VPS通用)

    https://www.tunnelbroker.net/tunnel_detail.php?tid=322922

  6. java容器简要概述

    java中集合框架的概述 java集合类主要用于保存对象的. 常用的集合对象: Colletion接口,Collection接口是集合中的顶层容器,表示的是一组对象,它的下面有两个子接口List接口和 ...

  7. java生成base64编码的png

    java代码: 引用包: import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java. ...

  8. OSIC Performance Bot

    https://github.com/lbragstad/keystone-performance

  9. 新建MMS草稿保存后,再进入草稿修改收件人,退出到会话界面,会显示两条草稿

    分析原因:新建彩信草稿,保存后,再打开草稿,修改收件人,再保存会产生新的threadId, 而之前保存的草稿theadId还存在,导致此问题. (必现. 解决方法:将原来的Thread_id和新的收件 ...

  10. java获取系统信息

    public class SystemInfo { public static void main(String[] args) { //系统属性 Properties prop = System.g ...