本文整理汇总了C++中CBitmap类的典型用法代码示例。如果您正苦于以下问题:C++ CBitmap类的具体用法?C++ CBitmap怎么用?C++ CBitmap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBitmap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dc
//重画消息
void CButtonBar::OnPaint()
{
CPaintDC dc(this);
//获取位置
CRect rcRect;
GetClientRect(&rcRect);
//加载资源
CImageHandle ImageHotHandle(&m_ImageHot);
CImageHandle ImageActiveHandle(&m_ImageActive);
CImageHandle ImageNormalHandle(&m_ImageNormal);
CImageHandle m_ImageBackGroundHandle(&m_ImageBackGround);
//建立缓冲
CDC BufferDC;
CBitmap BufferBmp;
BufferDC.CreateCompatibleDC(&dc);
BufferBmp.CreateCompatibleBitmap(&dc,rcRect.Width(),rcRect.Height());
BufferDC.SelectObject(&BufferBmp);
//绘画背景
CBrush BackBrush(TITLE_GROUND_COLOR);
CPen BorderPen(PS_SOLID,1,CSkinWndObject::m_SkinAttribute.m_crInsideBorder);
CPen * pOldPen=BufferDC.SelectObject(&BorderPen);
CBrush * pOldBrush=BufferDC.SelectObject(&BackBrush);
BufferDC.FillSolidRect(&rcRect,CSkinWndObject::m_SkinAttribute.m_crBackGround);
BufferDC.RoundRect(&rcRect,CPoint(10,10));
m_ImageBackGround.BitBlt(BufferDC,1,rcRect.Height()-m_ImageBackGround.GetHeight()-3);
BufferDC.SelectObject(pOldPen);
BufferDC.SelectObject(pOldBrush);
BackBrush.DeleteObject();
BorderPen.DeleteObject();
//绘画按钮
BufferDC.SetBkMode(TRANSPARENT);
BufferDC.SelectObject(&CSkinAttribute::m_DefaultFont);
//绘画按钮
CRect rcButton;
CSkinImage * pSkinImage=NULL;
for (INT_PTR i=0; i<m_OptionsItemPtr.GetCount(); i++)
{
LPCTSTR pszButtonText=m_OptionsItemPtr[i]->GetButtonText();
rcButton.SetRect(1,(int)(ITEM_HEIGHT*i+10+2*i),rcRect.Width(),(int)(ITEM_HEIGHT*(i+1)+10+2*i));
if (i==m_nActiveItem)
{
pSkinImage=&m_ImageActive;
BufferDC.SetTextColor(RGB(0,0,0));
}
else if (i==m_nHotItem)
{
pSkinImage=&m_ImageHot;
BufferDC.SetTextColor(RGB(0,0,0));
}
else
{
pSkinImage=&m_ImageNormal;
BufferDC.SetTextColor(RGB(0,0,0));
}
pSkinImage->BitBlt(BufferDC,rcButton.left,rcButton.top,ITEM_WIDTH,ITEM_HEIGHT,0,0,SRCCOPY);
BufferDC.DrawText(pszButtonText,lstrlen(pszButtonText),rcButton,DT_END_ELLIPSIS|DT_VCENTER|DT_CENTER|DT_SINGLELINE);
}
//绘画界面
dc.BitBlt(0,0,rcRect.Width(),rcRect.Height(),&BufferDC,0,0,SRCCOPY);
//清理资源
BufferDC.DeleteDC();
BufferBmp.DeleteObject();
return;
}
示例2: dc
//重画函数
void CControlWnd::OnPaint()
{
CPaintDC dc(this);
//获取位置
CRect rcClient;
GetClientRect(&rcClient);
//创建缓冲
CDC BufferDC;
CBitmap BufferImage;
BufferDC.CreateCompatibleDC(&dc);
BufferImage.CreateCompatibleBitmap(&dc,rcClient.Width(),rcClient.Height());
BufferDC.SelectObject(&BufferImage);
//加载资源
CImageHandle HandleControlTop(&m_ImageControlTop);
CImageHandle HandleControlMid(&m_ImageControlMid);
CImageHandle HandleControlButtom(&m_ImageControlButtom);
CImageHandle HandleActionExplain(&m_ImageActionExplain);
//绘画背景
m_ImageControlTop.BitBlt(BufferDC,0,0);
for (int nImageYPos=m_ImageControlTop.GetHeight();nImageYPos<rcClient.Height();nImageYPos+=m_ImageControlMid.GetHeight())
{
m_ImageControlMid.BitBlt(BufferDC,0,nImageYPos);
}
m_ImageControlButtom.BitBlt(BufferDC,0,rcClient.Height()-m_ImageControlButtom.GetHeight());
//变量定义
int nYPos=5;
BYTE cbCurrentItem=0;
BYTE cbExcursion[3]={0,1,2};
BYTE cbItemKind[4]={WIK_LEFT,WIK_CENTER,WIK_RIGHT,WIK_PENG};
//绘画扑克
for (BYTE i=0;i<CountArray(cbItemKind);i++)
{
if ((m_cbActionMask&cbItemKind[i])!=0)
{
//绘画扑克
for (BYTE j=0;j<3;j++)
{
BYTE cbCardData=m_cbCenterCard;
if (i<CountArray(cbExcursion))
cbCardData=m_cbCenterCard+j-cbExcursion[i];
g_CardResource.m_ImageTableBottom.DrawCardItem(&BufferDC,cbCardData,j*26+12,nYPos+5);
}
//计算位置
int nXImagePos=0;
int nItemWidth=m_ImageActionExplain.GetWidth()/7;
if ((m_cbActionMask&cbItemKind[i])&WIK_PENG)
nXImagePos=nItemWidth;
//绘画标志
int nItemHeight=m_ImageActionExplain.GetHeight();
m_ImageActionExplain.BitBlt(BufferDC,126,nYPos+5,nItemWidth,nItemHeight,nXImagePos,0);
//绘画边框
if (cbCurrentItem==m_cbCurrentItem)
{
BufferDC.Draw3dRect(7,nYPos,rcClient.Width()-14,ITEM_HEIGHT,RGB(255,255,0),RGB(255,255,0));
}
//设置变量
++cbCurrentItem;
nYPos+=ITEM_HEIGHT;
}
}
//杠牌扑克
for (BYTE i=0;i<CountArray(m_cbGangCard);i++)
{
if (m_cbGangCard[i]!=0)
{
//绘画扑克
for (BYTE j=0;j<4;j++)
{
g_CardResource.m_ImageTableBottom.DrawCardItem(&BufferDC,m_cbGangCard[i],j*26+12,nYPos+5);
}
//绘画边框
if (cbCurrentItem==m_cbCurrentItem)
{
BufferDC.Draw3dRect(7,nYPos,rcClient.Width()-14,ITEM_HEIGHT,RGB(255,255,0),RGB(255,255,0));
}
//绘画标志
int nItemWidth=m_ImageActionExplain.GetWidth()/7;
int nItemHeight=m_ImageActionExplain.GetHeight();
m_ImageActionExplain.BitBlt(BufferDC,126,nYPos+5,nItemWidth,nItemHeight,nItemWidth*3,0);
//设置变量
cbCurrentItem++;
nYPos+=ITEM_HEIGHT;
}
else
break;
//.........这里部分代码省略.........
示例3: Attach
/*
Attach()
Collega la toolbar al controllo.
UINT nID l'id del controllo
const CSize& sizeButton dimensione (in pixel) del bottone (+2 rispetto al bitmap)
const CSize& sizeBitmap dimensione (in pixel) del bitmap usato per il bottone (-2 rispetto al bottone)
*/
BOOL CToolBarCtrlEx::Attach(const CSize& sizeButton,const CSize& sizeBitmap,UINT nID/*=(UINT)-1L*/,UINT nIDCold/*=(UINT)-1L*/,UINT nIDHot/*=(UINT)-1L*/)
{
BOOL bAttached = FALSE;
if(m_pToolBarButtonsList)
{
int nButtonsCount = m_pToolBarButtonsList->Count();
if(nButtonsCount > 0)
{
m_pTbArray = new TBBUTTON[nButtonsCount];
if(m_pTbArray)
{
TOOLBARBUTTON* t;
char szResourceString[32];
int nOfs = 0;
int n;
memset(m_szToolBarTextStrings,'\0',sizeof(m_szToolBarTextStrings));
for(int i = 0; i < nButtonsCount; i++)
{
if((t = (TOOLBARBUTTON*)m_pToolBarButtonsList->GetAt(i))!=(TOOLBARBUTTON*)NULL)
{
memcpy((void*)&m_pTbArray[i],(void*)&t->button,sizeof(TBBUTTON));
if(t->text!=0L)
{
if((n = ::LoadString(NULL,t->text,szResourceString,sizeof(szResourceString)-1))!=0)
{
if(nOfs+n < sizeof(m_szToolBarTextStrings)-2)
{
memcpy(m_szToolBarTextStrings+nOfs,szResourceString,n);
nOfs += n+1;
}
}
}
}
else
memset((void*)&m_pTbArray[i],'\0',sizeof(TBBUTTON));
}
if(nIDCold!=(UINT)-1L && nIDHot!=(UINT)-1L)
{
CImageList imageList;
CBitmap bitmap;
// lista immagini standard
bitmap.LoadBitmap(nIDCold);
imageList.Create(sizeBitmap.cx,sizeBitmap.cy,ILC_COLORDDB|ILC_MASK,nButtonsCount,1);
imageList.Add(&bitmap,RGB(255,0,255));
this->SendMessage(TB_SETIMAGELIST,0,(LPARAM)imageList.m_hImageList);
imageList.Detach();
bitmap.Detach();
// lista immagini 'hot'
bitmap.LoadBitmap(nIDHot);
imageList.Create(sizeBitmap.cx,sizeBitmap.cy,ILC_COLORDDB|ILC_MASK,nButtonsCount,1);
imageList.Add(&bitmap,RGB(255,0,255));
this->SendMessage(TB_SETHOTIMAGELIST,0,(LPARAM)imageList.m_hImageList);
imageList.Detach();
bitmap.Detach();
bAttached = TRUE;
}
else if(nID!=(UINT)-1L)
{
CToolBarCtrl::SetBitmapSize(sizeButton);
CToolBarCtrl::SetBitmapSize(sizeBitmap);
CToolBarCtrl::AddBitmap(nButtonsCount,nID);
bAttached = TRUE;
}
if(bAttached)
{
if(m_szToolBarTextStrings[0]!='\0')
CToolBarCtrl::AddStrings(m_szToolBarTextStrings);
CToolBarCtrl::AddButtons(nButtonsCount,m_pTbArray);
CToolBarCtrl::AutoSize();
}
}
}
}
return(bAttached);
}
示例4: GetDC
void CTreeOptionsCtrlEx::OnCreateImageList()
{
CDC* pDCScreen = GetDC();
if (pDCScreen)
{
const int iBmpWidth = 16;
const int iBmpHeight = 17;
const int iBitmaps = 13;
CBitmap bmpControls;
if (bmpControls.CreateCompatibleBitmap(pDCScreen, iBmpWidth*iBitmaps, iBmpHeight))
{
if (m_ilTree.Create(iBmpWidth, iBmpHeight, m_uImageListColorFlags | ILC_MASK, 0, 1))
{
CDC dcMem;
if (dcMem.CreateCompatibleDC(pDCScreen))
{
HTHEME hTheme = (g_xpStyle.IsThemeActive() && g_xpStyle.IsAppThemed()) ? g_xpStyle.OpenThemeData(NULL, L"BUTTON") : NULL;
CBitmap* pOldBmp = dcMem.SelectObject(&bmpControls);
dcMem.FillSolidRect(0, 0, iBmpWidth*iBitmaps, iBmpHeight, GetSysColor(COLOR_WINDOW));
//int iCtrlWidth = iBmpWidth - 2;
//int iCtrlHeight = iBmpHeight - 2;
int iCtrlWidth = 16 - 3;
int iCtrlHeight = 16 - 3;
int iCtrlLeft = (iBmpWidth - iCtrlWidth) / 2;
int iCtrlTop = (iBmpHeight - iCtrlHeight) / 2;
// checkbox
CRect rcBmp(0, 0, 0+iBmpWidth, 0+iBmpHeight);
CRect rcCtrl(iCtrlLeft, iCtrlTop, iCtrlLeft+iCtrlWidth, iCtrlTop+iCtrlHeight);
if (hTheme){
g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_UNCHECKEDNORMAL, &rcCtrl, NULL);
g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_UNCHECKEDNORMAL, &rcCtrl, 0, 0, NULL);
}
else
dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_FLAT);
// checkbox checked
rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*1);
if (hTheme){
g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_CHECKEDNORMAL, &rcCtrl, NULL);
g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_CHECKEDNORMAL, &rcCtrl, 0, 0, NULL);
}
else
dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_FLAT);
// radio
rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*2);
if (hTheme){
g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL, &rcCtrl, NULL);
g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, RBS_UNCHECKEDNORMAL, &rcCtrl, 0, 0, NULL);
} else
dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONRADIO | DFCS_FLAT);
// radio checked
rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*3);
if (hTheme){
g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_RADIOBUTTON, RBS_CHECKEDNORMAL, &rcCtrl, NULL);
g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, RBS_CHECKEDNORMAL, &rcCtrl, 0, 0, NULL);
} else
dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_FLAT);
// checkbox disabled
rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*4);
if (hTheme){
g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_UNCHECKEDDISABLED, &rcCtrl, NULL);
g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_UNCHECKEDDISABLED, &rcCtrl, 0, 0, NULL);
} else
dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_INACTIVE | DFCS_FLAT);
// checkbox checked disabled
rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*5);
if (hTheme){
g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_CHECKEDDISABLED, &rcCtrl, NULL);
g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_CHECKEDDISABLED, &rcCtrl, 0, 0, NULL);
} else
dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT);
// radio disabled
rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*6);
if (hTheme){
g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_RADIOBUTTON, RBS_UNCHECKEDDISABLED, &rcCtrl, NULL);
g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, RBS_UNCHECKEDDISABLED, &rcCtrl, 0, 0, NULL);
} else
dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONRADIO | DFCS_INACTIVE | DFCS_FLAT);
// radio checked disabled
rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*7);
if (hTheme){
g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_RADIOBUTTON, RBS_CHECKEDDISABLED, &rcCtrl, NULL);
g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, RBS_CHECKEDDISABLED, &rcCtrl, 0, 0, NULL);
} else
dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT);
// checkbox checked tri-state
rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*8);
if (hTheme){
g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_MIXEDNORMAL, &rcCtrl, NULL);
g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_MIXEDNORMAL, &rcCtrl, 0, 0, NULL);
} else
//.........这里部分代码省略.........
示例5: DrawItem
void CSkinListBox::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
//没有节点就不用继续执行了
if( GetCount()==0 ) return;
//变量定义
CRect rcItem=lpDrawItemStruct->rcItem;
CDC * pDCControl=CDC::FromHandle(lpDrawItemStruct->hDC);
//创建缓冲
CDC BufferDC;
CBitmap ImageBuffer;
BufferDC.CreateCompatibleDC(pDCControl);
ImageBuffer.CreateCompatibleBitmap(pDCControl,rcItem.Width(),rcItem.Height());
//设置环境
BufferDC.SelectObject(&ImageBuffer);
BufferDC.SelectObject(GetCtrlFont());
//获取字符
CString strString;
GetText(lpDrawItemStruct->itemID,strString);
//计算位置
CRect rcString;
rcString.SetRect(4,0,rcItem.Width()-8,rcItem.Height());
//颜色定义
COLORREF crTextColor=((lpDrawItemStruct->itemState&ODS_SELECTED)!=0)?m_colSelectText:m_colNormalText;
//绘画背景
BufferDC.FillSolidRect(0,0,rcItem.Width(),rcItem.Height(),m_colBack);
//节点选中
if ( (lpDrawItemStruct->itemState&ODS_SELECTED) != 0 )
{
if ( m_pSelectImg!= NULL && !m_pSelectImg->IsNull() )
{
m_pSelectImg->Draw(&BufferDC,CRect(0,0,rcItem.Width(),rcItem.Height()));
}
}
//节点高亮
else if ( m_nHovenItem == lpDrawItemStruct->itemID )
{
if ( m_pBackImgH!= NULL && !m_pBackImgH->IsNull() )
{
m_pBackImgH->Draw(&BufferDC,CRect(0,0,rcItem.Width(),rcItem.Height()));
}
}
//绘画字符
BufferDC.SetBkMode(TRANSPARENT);
BufferDC.SetTextColor(crTextColor);
BufferDC.DrawText(strString,&rcString,DT_VCENTER|DT_SINGLELINE);
//绘画界面
pDCControl->BitBlt(rcItem.left,rcItem.top,rcItem.Width(),rcItem.Height(),&BufferDC,0,0,SRCCOPY);
//清理资源
BufferDC.DeleteDC();
ImageBuffer.DeleteObject();
}
示例6: file
CSmfReadMap::CSmfReadMap(std::string mapname)
: file(mapname)
{
PrintLoadMsg("Opening map file");
ConfigureAnisotropy();
usePBO = !!configHandler->Get("UsePBO", 1);
for(int a=0;a<1024;++a){
for(int b=0;b<3;++b){
float c=max(mapInfo->water.minColor[b],mapInfo->water.baseColor[b]-mapInfo->water.absorb[b]*a);
waterHeightColors[a*4+b]=(unsigned char)(c*210);
}
waterHeightColors[a*4+3]=1;
}
const SMFHeader& header = file.GetHeader();
width=header.mapx;
height=header.mapy;
gs->mapx=header.mapx;
gs->mapy=header.mapy;
gs->mapSquares = gs->mapx*gs->mapy;
gs->hmapx=gs->mapx/2;
gs->hmapy=gs->mapy/2;
gs->pwr2mapx=next_power_of_2(gs->mapx);
gs->pwr2mapy=next_power_of_2(gs->mapy);
// logOutput.Print("%i %i",gs->mapx,gs->mapy);
float3::maxxpos=gs->mapx*SQUARE_SIZE-1;
float3::maxzpos=gs->mapy*SQUARE_SIZE-1;
heightmap=new float[(gs->mapx+1)*(gs->mapy+1)];
const CMapInfo::smf_t& smf = mapInfo->smf;
const float minH = smf.minHeightOverride ? smf.minHeight : header.minHeight;
const float maxH = smf.maxHeightOverride ? smf.maxHeight : header.maxHeight;
const float base = minH;
const float mod = (maxH - minH) / 65536.0f;
file.ReadHeightmap(heightmap, base, mod);
CReadMap::Initialize();
for (unsigned int a = 0; a < mapname.size(); ++a) {
mapChecksum += mapname[a];
mapChecksum *= mapname[a];
}
PrintLoadMsg("Loading detail textures");
detailTexName = mapInfo->smf.detailTexName;
CBitmap bm;
if (!bm.Load(detailTexName)) {
throw content_error("Could not load detail texture from file " + detailTexName);
}
glGenTextures(1, &detailTex);
glBindTexture(GL_TEXTURE_2D, detailTex);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glBuildMipmaps(GL_TEXTURE_2D, GL_RGBA8, bm.xsize, bm.ysize, GL_RGBA, GL_UNSIGNED_BYTE, bm.mem);
if (anisotropy != 0.0f) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);
}
PrintLoadMsg("Creating overhead texture");
unsigned char* buf=new unsigned char[MINIMAP_SIZE];
file.ReadMinimap(buf);
glGenTextures(1, &minimapTex);
glBindTexture(GL_TEXTURE_2D, minimapTex);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
int offset=0;
for (unsigned int i = 0; i < MINIMAP_NUM_MIPMAP; i++) {
int mipsize = 1024>>i;
int size = ((mipsize+3)/4)*((mipsize+3)/4)*8;
glCompressedTexImage2DARB(GL_TEXTURE_2D, i, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, mipsize, mipsize, 0, size, buf + offset);
offset += size;
}
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, MINIMAP_NUM_MIPMAP-1 );
delete[] buf;
PrintLoadMsg("Creating ground shading");
unsigned char* bufZero = new unsigned char[gs->pwr2mapx * gs->pwr2mapy * 4];
memset(bufZero, 0, gs->pwr2mapx * gs->pwr2mapy * 4);
glGenTextures(1, &shadowTex);
glBindTexture(GL_TEXTURE_2D, shadowTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, gs->pwr2mapx, gs->pwr2mapy, 0, GL_RGBA, GL_UNSIGNED_BYTE, bufZero);
//.........这里部分代码省略.........
示例7: ASSERT_VALID
void CBCGPHeaderCtrl::OnDrawItem (CDC* pDC, int iItem, CRect rect, BOOL bIsPressed,
BOOL bIsHighlighted)
{
ASSERT_VALID (this);
ASSERT_VALID (pDC);
const int nTextMargin = 5;
//-------------
// Draw border:
//-------------
CBCGPVisualManager::GetInstance ()->OnDrawHeaderCtrlBorder (this, pDC,
rect, bIsPressed, bIsHighlighted);
if (iItem < 0)
{
return;
}
int nSortVal = 0;
if (m_mapColumnsStatus.Lookup (iItem, nSortVal) &&
nSortVal != 0)
{
//-----------------
// Draw sort arrow:
//-----------------
CRect rectArrow = rect;
rectArrow.DeflateRect (5, 5);
rectArrow.left = rectArrow.right - rectArrow.Height ();
if (bIsPressed)
{
rectArrow.right++;
rectArrow.bottom++;
}
rect.right = rectArrow.left - 1;
int dy2 = (int) (.134 * rectArrow.Width ());
rectArrow.DeflateRect (0, dy2);
m_bAscending = nSortVal > 0;
OnDrawSortArrow (pDC, rectArrow);
}
HD_ITEM hdItem;
memset (&hdItem, 0, sizeof (hdItem));
hdItem.mask = HDI_FORMAT | HDI_BITMAP | HDI_TEXT | HDI_IMAGE;
TCHAR szText [256];
hdItem.pszText = szText;
hdItem.cchTextMax = 255;
if (!GetItem (iItem, &hdItem))
{
return;
}
//-----------------------
// Draw bitmap and image:
//-----------------------
if ((hdItem.fmt & HDF_IMAGE) && hdItem.iImage >= 0)
{
// By Max Khiszinsky:
//---------------------------------------
// The column has a image from imagelist:
//---------------------------------------
CImageList* pImageList = GetImageList ();
if (pImageList != NULL)
{
int cx = 0;
int cy = 0;
VERIFY (::ImageList_GetIconSize (*pImageList, &cx, &cy));
CPoint pt = rect.TopLeft ();
pt.x ++;
pt.y = (rect.top + rect.bottom - cy) / 2;
VERIFY (pImageList->Draw (pDC, hdItem.iImage, pt, ILD_NORMAL));
rect.left += cx;
}
}
if ((hdItem.fmt & (HDF_BITMAP | HDF_BITMAP_ON_RIGHT)) && hdItem.hbm != NULL)
{
CBitmap* pBmp = CBitmap::FromHandle (hdItem.hbm);
ASSERT_VALID (pBmp);
BITMAP bmp;
pBmp->GetBitmap (&bmp);
CRect rectBitmap = rect;
if (hdItem.fmt & HDF_BITMAP_ON_RIGHT)
{
rectBitmap.right--;
rect.right = rectBitmap.left = rectBitmap.right - bmp.bmWidth;
}
//.........这里部分代码省略.........
示例8: getParent
void CDisplayView::drawofl(void)
{
CFrame *parentframe = getParent();
if(!parentframe) return;
CDrawContext *srccon;
long dsplw,dsplh;
#if 1 // quantise near-grey to grey for transparent-draw
// could be removed if q'ed bitmap is compiled to resource
if(stConverted==false)
{
stConverted = true;
srccon = new CDrawContext(parentframe,0);
COffscreenContext *charcon;
CColor pcl;
int w,h;
for(int nf=0; nf<kNumFtTypes; nf++)
{
dsplw = stFonts[nf].font->getWidth();
dsplh = stFonts[nf].font->getHeight();
charcon = new COffscreenContext(srccon,stFonts[nf].font,true);
CPoint cp = CPoint(0,0);
CRect cr = CRect(0,0, dsplw,dsplh);
stFonts[nf].font->draw(charcon, cr, cp );
for(w=0; w<dsplw; w++)
{
for(h=0; h<dsplh; h++)
{
#define RNG 14
pcl = charcon->getPoint(CPoint(w,h));
if( pcl.red==128 && pcl.green==128 && pcl.blue==128 ) continue;
if(pcl.red<(128-RNG) || pcl.red>128+RNG) continue;
if(pcl.green<(128-RNG) || pcl.green>128+RNG) continue;
if(pcl.blue<(128-RNG) || pcl.blue>128+RNG) continue;
pcl.red=pcl.green=pcl.blue = 128;
charcon->drawPoint(CPoint(w,h), pcl);
}
}
delete charcon;
}
delete srccon;
}
#endif
#if 0 // 0=PixelDrawing, else transparent drawing
COffscreenContext *charcon;
CPoint cp;
CRect cr;
char c;
dsplw = mDsplBmp->getWidth();
dsplh = mDsplBmp->getHeight();
CBitmap *bgnd = parentframe->getBackground();
// get fresh background image
cp = CPoint(size.left+mXAlign,size.top+mYAlign);
cr = CRect(0,0,dsplw,dsplh);
srccon = new CDrawContext(parentframe,0);
COffscreenContext *dspcon = new COffscreenContext(srccon,mDsplBmp,true);
bgnd->draw(dspcon, cr, cp);
// get fresh font image
cp = CPoint(0,0);
cr = CRect(0,0, mFontBmp->getWidth(),mFontBmp->getHeight());
charcon = new COffscreenContext(parentframe,mFontBmp->getWidth(),mFontBmp->getHeight());
CColor scl,dcl;
mFontBmp->draw(charcon, cr, cp );
for(int i=0; i<mCharsfit && (c = mText[i]); i++)
{
int h,w,wd = i*mPaintWidth;
int ws = (c - 33) * mCharWidth; // left position in font
if(ws < 0)
{
continue;
}
for(w=0,ws+=mCharOfs; w<(mCharWidth-mCharOfs); w++,ws++,wd++)
{
for(h=0; h<dsplh; h++)
{
scl = charcon->getPoint(CPoint(ws,h));
if( scl.red==128 && scl.green==128 && scl.blue==128 ) continue;
dcl = dspcon->getPoint(CPoint(wd,h));
dcl.red = stClip[scl.red + (scl.red>>1) + dcl.red];
dcl.green = stClip[scl.green + (scl.green>>1) + dcl.green];
dcl.blue = stClip[scl.blue + (scl.blue>>1) + dcl.blue];
dspcon->drawPoint(CPoint(wd,h), dcl);
}
}
}
delete srccon;
delete dspcon;
//.........这里部分代码省略.........
示例9: string
void CSm3ReadMap::Initialize (const char *mapname)
{
try {
string lmsg = "Loading " + string(mapname);
PrintLoadMsg(lmsg.c_str());
GLint tu;
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &tu);
renderer = SAFE_NEW terrain::Terrain;
renderer->config.cacheTextures=false;
renderer->config.forceFallbackTexturing = !!configHandler.GetInt("SM3ForceFallbackTex", 0);
if (!renderer->config.forceFallbackTexturing && GLEW_ARB_fragment_shader && GLEW_ARB_shading_language_100) {
renderer->config.useBumpMaps = true;
renderer->config.anisotropicFiltering = 0.0f;
}
renderer->config.useStaticShadow = false;
renderer->config.terrainNormalMaps = false;
renderer->config.normalMapLevel = 3;
if (shadowHandler->drawShadows)
renderer->config.useShadowMaps = true;
if (!mapInfo->sm3.minimap.empty()) {
CBitmap bmp;
if(bmp.Load(mapInfo->sm3.minimap))
minimapTexture=bmp.CreateTexture(true);
}
/* int numStages=atoi(mapDefParser.SGetValueDef("0", "map\\terrain\\numtexturestages").c_str());
int maxStages=configHandler.GetInt("SM3MaxTextureStages", 10);
if (numStages > maxStages) {
renderer->config.cacheTextures = true;
renderer->config.cacheTextureSize = 256;
// renderer->config.detailMod
}
*/
Sm3LoadCB loadcb;
terrain::LightingInfo lightInfo;
lightInfo.ambient = mapInfo->light.groundAmbientColor;
terrain::StaticLight light;
light.color = mapInfo->light.groundSunColor;
light.directional = false;
light.position = mapInfo->light.sunDir *1000000;
lightInfo.staticLights.push_back (light);
renderer->Load (GetMapDefParser(), &lightInfo, &loadcb);
height = width = renderer->GetHeightmapWidth ()-1;
// Set global map info
gs->mapx=width;
gs->mapy=height;
gs->mapSquares = width*height;
gs->hmapx=width/2;
gs->hmapy=height/2;
gs->pwr2mapx=next_power_of_2(width);
gs->pwr2mapy=next_power_of_2(height);
float3::maxxpos=width*SQUARE_SIZE-1;
float3::maxzpos=height*SQUARE_SIZE-1;
CReadMap::Initialize();
const TdfParser& mapDefParser = GetMapDefParser();
if (mapDefParser.SectionExist("map\\featuretypes")) {
int numTypes = atoi(mapDefParser.SGetValueDef("0", "map\\featuretypes\\numtypes").c_str());
for (int a=0;a<numTypes;a++) {
char loc[100];
SNPRINTF(loc, 100, "map\\featuretypes\\type%d", a);
featureTypes.push_back (SAFE_NEW std::string(mapDefParser.SGetValueDef("TreeType0", loc)));
}
}
LoadFeatureData();
groundDrawer = SAFE_NEW CSm3GroundDrawer (this);
}
catch(content_error& e)
{
ErrorMessageBox(e.what(), "Error:", MBF_OK);
}
}
示例10: dc
void CIMMain::OnPaint()
{
CPaintDC dc(this);
// Create a memory DC compatible with the paint DC
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CRect rcClip, rcClient;
dc.GetClipBox( &rcClip );
GetClientRect(&rcClient);
// Select a compatible bitmap into the memory DC
CBitmap bitmap;
bitmap.CreateCompatibleBitmap( &dc, rcClient.Width(), rcClient.Height() );
memDC.SelectObject( &bitmap );
//dc.SetBkMode(TRANSPARENT);
// Set clip region to be same as that in paint DC
CRgn rgn;
rgn.CreateRectRgnIndirect( &rcClip );
memDC.SelectClipRgn(&rgn);
rgn.DeleteObject();
// First let the control do its default drawing.
CWnd::DefWindowProc(WM_PAINT, (WPARAM)memDC.m_hDC, 0);
HTREEITEM hItem = GetFirstVisibleItem();
int iItemCount = GetVisibleCount() + 1;
while(hItem && iItemCount--)
{
CRect rect;
// Do not meddle with selected items or drop highlighted items
UINT selflag = TVIS_DROPHILITED | TVIS_SELECTED;
Color_Font cf;
if ((GetItemState(hItem, selflag) & selflag)
&& ::GetFocus() == m_hWnd)
;
else if (m_mapColorFont.Lookup(hItem, cf))
{
CFont *pFontDC;
CFont fontDC;
LOGFONT logfont;
if(cf.logfont.lfFaceName[0] != '\0 ')
logfont = cf.logfont;
else {
// No font specified, so use window font
CFont *pFont = GetFont();
pFont-> GetLogFont( &logfont );
}
if(GetItemBold(hItem))
logfont.lfWeight = 700;
fontDC.CreateFontIndirect(&logfont);
pFontDC = memDC.SelectObject(&fontDC );
if(cf.color != (COLORREF) - 1)
memDC.SetTextColor(cf.color);
else
memDC.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
CString sItem = GetItemText(hItem);
GetItemRect(hItem, &rect, TRUE);
//memDC.SetBkColor( GetSysColor(COLOR_WINDOW ));
memDC.SetBkMode(TRANSPARENT);
memDC.TextOut(rect.left + 2, rect.top + 5, sItem);
memDC.SelectObject(pFontDC);
}
hItem = GetNextVisibleItem(hItem);
}
dc.BitBlt(rcClip.left, rcClip.top, rcClip.Width(), rcClip.Height(), &memDC,
rcClip.left, rcClip.top, SRCCOPY);
memDC.DeleteDC();
}
示例11: GetWindowRect
BOOL CDrawMandelbrotDlg::Draw()
{
CRect rect;
GetWindowRect(&rect);
int width = rect.Width();
int height = rect.Height();
m_top = m_bottom + (m_right - m_left) * height / width;
CClientDC dc(this);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CBitmap bmp;
bmp.CreateCompatibleBitmap(&dc, width, height);
memDC.SelectObject(&bmp);
BITMAPINFO bmpInfo;
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpInfo.bmiHeader.biWidth = width;
bmpInfo.bmiHeader.biHeight = -height;
bmpInfo.bmiHeader.biPlanes = 1;
bmpInfo.bmiHeader.biBitCount = 24;
bmpInfo.bmiHeader.biCompression = BI_RGB;
bmpInfo.bmiHeader.biSizeImage = 0;
bmpInfo.bmiHeader.biXPelsPerMeter = 3000;
bmpInfo.bmiHeader.biYPelsPerMeter = 3000;
bmpInfo.bmiHeader.biClrUsed = 0;
bmpInfo.bmiHeader.biClrImportant = 0;
long bytesPerLine = (bmpInfo.bmiHeader.biWidth * 3 + 3) / 4 * 4;
long bufferSize = bytesPerLine * height;
BYTE *buffer = new BYTE[bufferSize];
memset(buffer, 0, bufferSize);
int maxLoop = 1500;
double w = m_right - m_left;
double h = m_top - m_bottom;
int iTmp = -1;
int index = -1;
#pragma omp parallel for
for (int i = 0; i < width; ++i)
{
for (int j = 0; j < height; ++j)
{
ComplexNum z;
ComplexNum c;
double dTmp;
int loopCount = 0;
c.real = w * (i + 1) / width + m_left;
c.imag = h * (j + 1) / height + m_bottom;
do
{
dTmp = z.real * z.real - z.imag * z.imag + c.real;
z.imag = 2 * z.real * z.imag + c.imag;
z.real = dTmp;
++loopCount;
} while((z.real * z.real + z.imag * z.imag) < 4 && loopCount < maxLoop);
if (loopCount != maxLoop)
{
int iTmp = loopCount % 255;
index = j * bytesPerLine + i * 3;
buffer[index] = iTmp;
buffer[index + 1] = iTmp * 5;
buffer[index + 2] = iTmp * 10;
}
}
}
SetDIBits(dc.m_hDC, bmp, 0, height, buffer, &bmpInfo, DIB_RGB_COLORS);
delete []buffer;
dc.BitBlt(0, 0, bmpInfo.bmiHeader.biWidth, height, &memDC, 0, 0, SRCCOPY);
return true;
}
示例12: dc
void CIMTree::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rcClip, rcClient;
dc.GetClipBox( &rcClip );
GetClientRect(&rcClient);
// Create a compatible memory DC
CDC memDC;
memDC.CreateCompatibleDC( &dc );
// Select a compatible bitmap into the memory DC
CBitmap bitmap, bmpImage;
bitmap.CreateCompatibleBitmap( &dc, rcClient.Width(), rcClient.Height() );
CBitmap *OldBitmap = memDC.SelectObject( &bitmap );
// First let the control do its default drawing.
CTreeCtrl::DefWindowProc( WM_PAINT, (WPARAM)memDC.m_hDC, 0 );
/*
// create the font
CFont *pFontDC;
CFont fontDC, boldFontDC;
LOGFONT logfont;
CFont *pFont = GetFont();
pFont->GetLogFont( &logfont );
fontDC.CreateFontIndirect( &logfont ); //普通字体
pFontDC = memDC.SelectObject( &fontDC );
logfont.lfWeight = 700;
boldFontDC.CreateFontIndirect( &logfont ); //粗体字
// and now let's get to the painting itself
HTREEITEM hItem = GetFirstVisibleItem();
int n = GetVisibleCount();
hItem = GetFirstVisibleItem();
n = GetVisibleCount();
while(hItem!=NULL && n>=0)
{
CRect rect;
CRect m_labelRect;
UINT selflag = TVIS_SELECTED ; // |TVIS_DROPHILITED;
CString ItemText = GetItemText(hItem);
GetItemRect( hItem, &m_labelRect, TRUE ); //文字
GetItemRect( hItem, &rect, FALSE );
if ( !(GetItemState( hItem, selflag ) & selflag )) //选中状态
{
memDC.SetBkMode(TRANSPARENT);
memDC.SetTextColor(::GetSysColor (COLOR_WINDOWTEXT ));
DrawItemText(&memDC,ItemText,m_labelRect,LVCFMT_LEFT);
}
else
{
COLORREF m_highlightColor = ::GetSysColor (COLOR_HIGHLIGHT);
CBrush brush(m_highlightColor);
memDC.FillRect (m_labelRect, &brush);
// draw a dotted focus rectangle
memDC.DrawFocusRect (m_labelRect);
memDC.SetBkColor(m_highlightColor);
memDC.SetTextColor(::GetSysColor (COLOR_HIGHLIGHTTEXT));
memDC.SelectObject( &boldFontDC );
DrawItemText(&memDC,ItemText,m_labelRect,LVCFMT_LEFT);
memDC.SelectObject( &pFontDC );
}
hItem = GetNextVisibleItem( hItem );
n--;
}
memDC.SelectObject( pFontDC );
*/
// Draw bitmap in the background if one has been set
if( m_bitmap.m_hObject != NULL )
{
// Now create a mask
CDC maskDC;
maskDC.CreateCompatibleDC(&dc);
CBitmap maskBitmap;
//.........这里部分代码省略.........
示例13: dc
void CSkinVerticleScrollbar::Draw()
{
CClientDC dc(this);
CRect clientRect;
GetClientRect(&clientRect);
CMyMemDC memDC(&dc, &clientRect);
memDC.FillSolidRect(&clientRect, RGB(74,82,107));
CDC bitmapDC;
bitmapDC.CreateCompatibleDC(&dc);
CBitmap bitmap;
bitmap.LoadBitmap(IDB_VERTICLE_SCROLLBAR_TOP);
CBitmap* pOldBitmap = bitmapDC.SelectObject(&bitmap);
memDC.BitBlt(clientRect.left,clientRect.top,20,17,&bitmapDC,0,0,SRCCOPY);
bitmapDC.SelectObject(pOldBitmap);
bitmap.DeleteObject();
pOldBitmap = NULL;
bitmap.LoadBitmap(IDB_VERTICLE_SCROLLBAR_UPARROW);
pOldBitmap = bitmapDC.SelectObject(&bitmap);
memDC.BitBlt(clientRect.left,clientRect.top+17,20,19,&bitmapDC,0,0,SRCCOPY);
bitmapDC.SelectObject(pOldBitmap);
bitmap.DeleteObject();
pOldBitmap = NULL;
//draw the background (span)
bitmap.LoadBitmap(IDB_VERTICLE_SCROLLBAR_SPAN);
pOldBitmap = bitmapDC.SelectObject(&bitmap);
int nHeight = clientRect.Height() - 37;
memDC.StretchBlt(clientRect.left, clientRect.top+37, 20,nHeight,&bitmapDC, 0,0, 20, 1, SRCCOPY);
bitmapDC.SelectObject(pOldBitmap);
bitmap.DeleteObject();
pOldBitmap = NULL;
//draw the down arrow of the scrollbar
bitmap.LoadBitmap(IDB_VERTICLE_SCROLLBAR_DOWNARROW);
pOldBitmap = bitmapDC.SelectObject(&bitmap);
memDC.BitBlt(clientRect.left,nHeight,20,16,&bitmapDC,0,0,SRCCOPY);
bitmapDC.SelectObject(pOldBitmap);
bitmap.DeleteObject();
pOldBitmap = NULL;
//draw the down arrow of the scrollbar
bitmap.LoadBitmap(IDB_VERTICLE_SCROLLBAR_BOTTOM);
pOldBitmap = bitmapDC.SelectObject(&bitmap);
memDC.BitBlt(clientRect.left+1,nHeight+26,20,22,&bitmapDC,0,0,SRCCOPY);
bitmapDC.SelectObject(pOldBitmap);
bitmap.DeleteObject();
pOldBitmap = NULL;
//If there is nothing to scroll then don't
//show the thumb control otherwise show it
if(pList->GetScrollLimit(SB_VERT) != 0)
{
//draw the thumb control
bitmap.LoadBitmap(IDB_VERTICLE_SCROLLBAR_THUMB);
pOldBitmap = bitmapDC.SelectObject(&bitmap);
memDC.BitBlt(clientRect.left,clientRect.top+nThumbTop,20,26,&bitmapDC,0,0,SRCCOPY);
bitmapDC.SelectObject(pOldBitmap);
bitmap.DeleteObject();
pOldBitmap = NULL;
}
}
示例14: GetDocument
void CViewSockTrackerImage::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// 這邊畫 圖片
/////////////////////////////////////////////////////////////////////
CRect RectImage;
GetClientRect( &RectImage );
if(m_pBitmap != NULL && csInfomation == "" )
{
CBitmap bmp;
if(bmp.Attach(m_pBitmap))
{
CString csW = _T("");
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo);
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC);
dcMemory.SelectObject(&bmp);
pDC->SetStretchBltMode(HALFTONE);
pDC->StretchBlt(RectImage.left,RectImage.top,RectImage.Width(),RectImage.Height(),&dcMemory,0,0,
bmpInfo.bmWidth,bmpInfo.bmHeight,SRCCOPY);
bmp.Detach();
//
m_w = bmpInfo.bmWidth;
m_h = bmpInfo.bmHeight;
}
}
//
// 這邊畫 Pattern ROI
/////////////////////////////////////////////////////////////////////
if(m_pBitmap != NULL && csInfomation == "" )
{
CRect rect;
COLORREF color = RGB(255, 255, 0);
m_AlignRectTracker.SetRectColor( color );
m_AlignRectTracker.GetTrueRect(&rect);
if( m_bLoadRect )
{
m_bLoadRect = false;
m_AlignRectTracker.m_rect = m_LoadRect;
m_AlignRectTracker.Draw( pDC, m_LoadRect );
}
else
m_AlignRectTracker.Draw( pDC );
}
/////////////////////////////////////////////////////////////////////
if( csInfomation != "" )
{
CRect RectText;
GetClientRect( &RectText );
int x = 0;
int y = 0;
x = 20;
y = RectText.Height() / 2;
pDC->TextOut( x, y, csInfomation );
pDC->TextOut( x, y + 15 , "Image is lost" );
csInfomation = "";
}
//
m_pBitmap = NULL;
}
示例15: AddImage
void CDConsoleDlg::AddImage(CImageList& imageList, UINT id)
{
CBitmap bm;
bm.LoadBitmap(id);
imageList.Add(&bm, RGB(0, 0, 0));
}