-
大小: 101.02 KB文件類(lèi)型: .rar金幣: 1下載: 0 次發(fā)布日期: 2024-09-14
- 語(yǔ)言: 其他
- 標(biāo)簽:
資源簡(jiǎn)介
bmp位圖透明貼圖,可以在窗口,圖案,等上實(shí)現(xiàn)類(lèi)似png的透明效果,代碼簡(jiǎn)單,希望和大家一起學(xué)習(xí)好的東西,
代碼片段和文件信息
//?KbcBmp.cpp?:?implementation?file
//
#include?“stdafx.h“
#include?“KbcBmp.h“
#include?“resource.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CKbcBmp
IMPLEMENT_DYNCREATE(CKbcBmp?CView)
CKbcBmp::CKbcBmp()
{
}
CKbcBmp::~CKbcBmp()
{
}
BEGIN_MESSAGE_MAP(CKbcBmp?CView)
//{{AFX_MSG_MAP(CKbcBmp)
//?NOTE?-?the?ClassWizard?will?add?and?remove?mapping?macros?here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?CKbcBmp?drawing
void?CKbcBmp::OnDraw(CDC*?pDC)
{
CDocument*?pDoc?=?GetDocument();
//?TODO:?add?draw?code?here
}
/////////////////////////////////////////////////////////////////////////////
//?CKbcBmp?diagnostics
#ifdef?_DEBUG
void?CKbcBmp::AssertValid()?const
{
CView::AssertValid();
}
void?CKbcBmp::Dump(CDumpContext&?dc)?const
{
CView::Dump(dc);
}
#endif?//_DEBUG
/////////////////////////////////////////////////////////////////////////////
//?CKbcBmp?message?handlers
//?
void?CKbcBmp::LoadBitmap(CString?strFileName)
{
m_picImg.Load(strFileName);
m_nWidth =?m_picImg.m_Width;
m_nHeight =?m_picImg.m_Height;
m_nSliceWidth =?m_nWidth/4;
}
//?CKbcBmpButton?俊輯?齲免且?錠?靜綽?竊薦..?弊覆?匙厘撈?楷加利欄肺?嘿籃?巴闌?弊妨霖促.nSeq俊?蝶扼..
void?CKbcBmp::Draw(CDC?*pDCint?nSeqint?nXint?nYUINT?nMask)
{
UINT?BLACK =?RGB(000);
UINT?WHITE =?RGB(255255255);
UINT?BMPWIDTH =?m_nWidth;
UINT?BMPHEIGHT =?m_nHeight;
UINT?MASK =?nMask;
UINT?SLICEWIDTH =?m_nSliceWidth;
UINT?INTERVAL =?SLICEWIDTH?*?nSeq;
CDC oriDC;
CDC srcDC;
CDC maskDC;
CDC memDC;
CBitmap oriBmp;
CBitmap srcBmp;
CBitmap maskBmp;
CBitmap memBmp;
CBitmap *pOldoriDC;
CBitmap *pOldsrcDC;
CBitmap *pOldmaskDC;
CBitmap *pOldmemDC;
//?we?draw?whole?button?image?to?oriDC.
oriDC.CreateCompatibleDC(pDC);
oriBmp.CreateCompatibleBitmap(pDCm_nWidthm_nHeight);
pOldoriDC?=?oriDC.Selectobject(&oriBmp);
m_picImg.Show(&oriDCCRect(00m_nWidthm_nHeight));
//////////////////////////////////////////////////////
//?then?copy?1/4?button?image?to?srcDC.
//?if?user?wanna?draw?disable?button?then?copy?fourth?image?of?oriDC?to?srcDC.
srcDC.CreateCompatibleDC(pDC);
srcBmp.CreateCompatibleBitmap(pDCSLICEWIDTHBMPHEIGHT);
pOldsrcDC?=?srcDC.Selectobject(&srcBmp);
srcDC.BitBlt(00SLICEWIDTHBMPHEIGHT&oriDCINTERVAL0SRCCOPY);
//////////////////////////////////////////////////////
//?make?maskDC
//?mask?image?made?by?black?and?white.
//?black?region?is?we?wanna?draw??white?region?is?we?don‘t?wanna?draw.
maskDC.CreateCompatibleDC(pDC);
maskBmp.CreateBitmap(SLICEWIDTHBMPHEIGHT11NULL);
pOldmaskDC?=?maskDC.Selectobject(&maskBmp);
srcDC.SetBkColor(MASK);
maskDC.BitBlt(00SLICEWIDTHBMPHEIGHT&srcDC00SRC
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件??????57563??2004-10-31?22:23??位圖透明貼圖\bg.jpg
?????文件???????4174??2004-10-31?22:10??位圖透明貼圖\KbcBmp.cpp
?????文件???????1770??2004-10-31?21:33??位圖透明貼圖\KbcBmp.h
?????文件???????4344??2004-10-31?22:29??位圖透明貼圖\KbcButton.cpp
?????文件???????2728??2004-10-31?22:49??位圖透明貼圖\KbcButton.h
?????文件??????21407??2001-09-04?20:52??位圖透明貼圖\Picture.cpp
?????文件???????1560??2001-09-04?20:53??位圖透明貼圖\Picture.h
?????文件??????22244??2004-10-31?20:59??位圖透明貼圖\play.bmp
?????文件???????3651??2003-07-30?16:11??位圖透明貼圖\ReadMe.txt
?????文件????????917??2004-10-31?20:43??位圖透明貼圖\resource.h
?????文件????????326??2003-07-31?14:31??位圖透明貼圖\res\cursor1.cur
?????文件???????1078??2003-07-30?16:11??位圖透明貼圖\res\TestButton.ico
?????文件????????402??2003-07-30?16:11??位圖透明貼圖\res\TestButton.rc2
?????文件???????5093??2004-10-31?20:21??位圖透明貼圖\show.gif
?????文件????????212??2003-07-30?16:11??位圖透明貼圖\StdAfx.cpp
?????文件???????1054??2003-07-30?16:11??位圖透明貼圖\StdAfx.h
?????文件???????1121??2004-10-31?22:14??位圖透明貼圖\TestButton.clw
?????文件???????2119??2003-07-30?16:11??位圖透明貼圖\TestButton.cpp
?????文件???????4676??2004-10-31?17:31??位圖透明貼圖\TestButton.dsp
?????文件????????543??2003-07-30?16:11??位圖透明貼圖\TestButton.dsw
?????文件???????1368??2003-07-30?16:11??位圖透明貼圖\TestButton.h
?????文件???????4924??2004-10-31?22:14??位圖透明貼圖\TestButton.rc
?????文件???????4015??2004-10-31?22:28??位圖透明貼圖\TestButtonDlg.cpp
?????文件???????1591??2004-10-31?21:19??位圖透明貼圖\TestButtonDlg.h
?????文件??????66560??2009-09-12?09:24??位圖透明貼圖\TestButton.ncb
?????文件????????254??2009-09-12?09:24??位圖透明貼圖\TestButton.plg
?????文件??????53760??2009-09-12?09:24??位圖透明貼圖\TestButton.opt
?????目錄??????????0??2009-09-11?20:52??位圖透明貼圖\res
?????目錄??????????0??2009-09-11?20:52??位圖透明貼圖
-----------?---------??----------?-----??----
............此處省略2個(gè)文件信息
評(píng)論
共有 條評(píng)論