资源简介

《MFC游戏开发》笔记三 透明贴图 配套源代码 欢迎大家关注配套博文:http://blog.csdn.net/u011371356/article/details/9313239#reply

资源截图

代码片段和文件信息


// ChildView.cpp : CChildView 类的实现
//

#include “stdafx.h“
#include “GameMFC2.h“
#include “ChildView.h“

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CChildView

CChildView::CChildView()
{
}

CChildView::~CChildView()
{
}


BEGIN_MESSAGE_MAP(CChildView CWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()

//将png贴图透明
void TransparentPNG(CImage *png)
{
for(int i = 0; i GetWidth(); i++)
{
for(int j = 0; j GetHeight(); j++)
{
unsigned char* pucColor = reinterpret_cast(png->GetPixelAddress(i  j));
pucColor[0] = pucColor[0] * pucColor[3] / 255;
pucColor[1] = pucColor[1] * pucColor[3] / 255;
pucColor[2] = pucColor[2] * pucColor[3] / 255;
}
}
}

// CChildView 消息处理程序

BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs) 
{
if (!CWnd::PreCreateWindow(cs))
return FALSE;

cs.dwExstyle |= WS_EX_CLIENTEDGE;
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS 
::LoadCursor(NULL IDC_ARROW) reinterpret_cast(COLOR_WINDOW+1) NULL);

//创建兼容的DC
m_bgcDC.CreateCompatibleDC(NULL);
//从资源中加载位图
m_bgBitmap.LoadBitmap(IDB_BITMAP1);
//选择位图对象
m_bgcDC.Selectobject(&m_bgBitmap);
//加载英雄图片
m_hero.Load(“hero.png“);
TransparentPNG(&m_hero);


return TRUE;
}

void CChildView::OnPaint() 
{
//获取窗口DC指针
CDC *cDC=this->GetDC();
//获取窗口大小
GetClientRect(&m_client);
//贴图
cDC->BitBlt(00m_client.Width()m_client.Height()&m_bgcDC00SRCCOPY);
//释放DC
m_hero.Draw(*cDC1004006060);
ReleaseDC(cDC);
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    1957888  2013-07-12 16:44  GameMFC2\Debug\GameMFC2.exe

     文件    1583072  2013-07-12 16:44  GameMFC2\Debug\GameMFC2.ilk

     文件    5311488  2013-07-12 16:44  GameMFC2\Debug\GameMFC2.pdb

     文件    1440054  2013-07-12 15:18  GameMFC2\GameMFC2\bg.bmp

     文件       1635  2013-07-12 16:44  GameMFC2\GameMFC2\ChildView.cpp

     文件        539  2013-07-12 16:14  GameMFC2\GameMFC2\ChildView.h

     文件     129808  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\ChildView.obj

     文件       2946  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\cl.command.1.tlog

     文件      50598  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\CL.read.1.tlog

     文件       2716  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\CL.write.1.tlog

     文件        667  2013-07-11 13:13  GameMFC2\GameMFC2\Debug\GameMFC2.exe.embed.manifest

     文件        732  2013-07-12 15:53  GameMFC2\GameMFC2\Debug\GameMFC2.exe.embed.manifest.res

     文件        381  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\GameMFC2.exe.intermediate.manifest

     文件         60  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\GameMFC2.lastbuildstate

     文件       2221  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\GameMFC2.log

     文件      55073  2013-07-12 16:18  GameMFC2\GameMFC2\Debug\GameMFC2.obj

     文件   33751040  2013-07-12 15:50  GameMFC2\GameMFC2\Debug\GameMFC2.pch

     文件    1515404  2013-07-12 15:53  GameMFC2\GameMFC2\Debug\GameMFC2.res

     文件        206  2013-07-11 13:13  GameMFC2\GameMFC2\Debug\GameMFC2_manifest.rc

     文件          2  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\link-cvtres.read.1.tlog

     文件          2  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\link-cvtres.write.1.tlog

     文件          2  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\link.11008-cvtres.read.1.tlog

     文件          2  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\link.11008-cvtres.write.1.tlog

     文件          2  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\link.11008.read.1.tlog

     文件          2  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\link.11008.write.1.tlog

     文件          2  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\link.2012-cvtres.read.1.tlog

     文件          2  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\link.2012-cvtres.write.1.tlog

     文件          2  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\link.2012.read.1.tlog

     文件          2  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\link.2012.write.1.tlog

     文件          2  2013-07-12 16:44  GameMFC2\GameMFC2\Debug\link.6164-cvtres.read.1.tlog

............此处省略55个文件信息

评论

共有 条评论