//重画消息 VOID CCollocateBar::OnPaint() { CPaintDC dc(this); //获取位置 CRect rcClient; GetClientRect(&rcClient); //创建缓冲 CBitImage ImageBuffer; ImageBuffer.Create(rcClient.Width(),rcClient.Height(),32); //创建设备 CImageDC BufferDC(ImageBuffer); CDC * pBufferDC=CDC::FromHandle(BufferDC); //设置设备 pBufferDC->SetBkMode(TRANSPARENT); pBufferDC->SelectObject(CSkinResourceManager::GetInstance()->GetDefaultFont()); //加载资源 CPngImage ImageButton; CPngImage ImageBarLogo; ImageButton.LoadImage(AfxGetInstanceHandle(),TEXT("COLLOCATE_BAR_BT")); ImageBarLogo.LoadImage(AfxGetInstanceHandle(),TEXT("COLLOCATE_BAR_LOGO")); //绘画背景 pBufferDC->FillSolidRect(&rcClient,RGB(223,236,246)); ImageBarLogo.DrawImage(pBufferDC,rcClient.Width()-ImageBarLogo.GetWidth(),rcClient.Height()-ImageBarLogo.GetHeight()); //绘画按钮 for (INT i=0;i<m_CollocateItemArray.GetCount();i++) { //获取对象 ASSERT(m_CollocateItemArray[i]!=NULL); CCollocateItem * pCollocateItem=m_CollocateItemArray[i]; //变量定义 INT nXButtomPos=0; INT nYButtomPos=pCollocateItem->m_cbImageIndex*m_SizeButton.cy; //横行计算 if ((m_wItemHover==i)&&(m_wItemDown!=i)) nXButtomPos=m_SizeButton.cx*2; if ((m_wItemActive==i)||(m_wItemDown==i)) nXButtomPos=m_SizeButton.cx; //绘画按钮 INT nXDrawPos=(rcClient.Width()-m_SizeButton.cx)/2; INT nYDrawPos=(m_SizeButton.cy+BAR_BT_SPACE)*i+BAR_BT_EXCURSION; ImageButton.DrawImage(pBufferDC,nXDrawPos,nYDrawPos,m_SizeButton.cx,m_SizeButton.cy,nXButtomPos,nYButtomPos); } //绘画界面 dc.BitBlt(0,0,rcClient.Width(),rcClient.Height(),pBufferDC,0,0,SRCCOPY); return; }
//处理图片 bool CRichEditMessage::LoadRichEditImage(HINSTANCE hInstance, UINT uResourceID, CDataObject&ImageDataObject) { //加载图片 CBitImage ImageFile; ImageFile.LoadFromResource(hInstance,uResourceID); //失败判断 if (ImageFile.IsNull()==true) { ASSERT(FALSE); return false; } //创建表情 CImage ImageRichEdit; ImageRichEdit.Create(ImageFile.GetWidth(),ImageFile.GetHeight(),32); //绘画表情 CDC * pDC=CDC::FromHandle(ImageRichEdit.GetDC()); pDC->FillSolidRect(0,0,ImageFile.GetWidth(),ImageFile.GetHeight(),m_crFillColor); ImageFile.TransDrawImage(pDC,0,0,RGB(255,0,255)); //设置图片 ImageRichEdit.ReleaseDC(); ImageDataObject.SetImage(ImageRichEdit.Detach()); return true; }
//绘画函数 VOID CDlgRegWizardUserInfo::OnPaint() { CPaintDC dc(this); //绘画背景 CRect rcClient; GetClientRect(&rcClient); //绘画位图 CBitImage ImageBreviaryMap; ImageBreviaryMap.LoadFromResource(AfxGetInstanceHandle(),IDB_BREVIARY_MAP); ImageBreviaryMap.TransDrawImage(&dc,rcClient.Width()-ImageBreviaryMap.GetWidth()-15,35,RGB(255,0,255)); return; }
int SetPixel(lua_State *L) { int x = (int)lua_tointeger( L, -3 ); int y = (int)lua_tointeger( L, -2 ); bool bit = (int)lua_tointeger( L, -1 ) != 0; image.setPixel( x, y, bit ); return 0; }
int SetLine(lua_State *L) { int x = (int)lua_tointeger( L, -5 ); int y = (int)lua_tointeger( L, -4 ); int x2 = (int)lua_tointeger( L, -3 ); int y2 = (int)lua_tointeger( L, -2 ); bool bit = (int)lua_tointeger( L, -1 ) != 0; image.setLine( x, y, x2, y2, bit ); return 0; }
// args: bitmap pointer, mode, unknown, unknown, unknown int __stdcall GppDraw( unsigned char* pImg, int mode, int unknown1, int unknown2, int unknown3 ) { pgpplua->GppDraw( pImg, mode, unknown1, unknown2, unknown3 ); switch( mode ) { case 0: image.copyTo( pImg, 0 ); break; case 1: image.copyTo( pImg, 1 ); break; case 2: image.copyTo( pImg, 2 ); break; } return 0; }
//建立消息 INT CWndUserInfoCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct)==-1) return -1; //注册事件 CPlatformEvent * pPlatformEvent=CPlatformEvent::GetInstance(); if (pPlatformEvent!=NULL) pPlatformEvent->RegisterEventWnd(m_hWnd); //加载资源 CBitImage ImageTitleM; ImageTitleM.LoadFromResource(AfxGetInstanceHandle(),IDB_USER_INFO_M); //创建按钮 CRect rcCreate(0,0,0,0); m_btUserInfo1.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,rcCreate,this,IDC_USER_INFO_1); m_btUserInfo2.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,rcCreate,this,IDC_USER_INFO_2); m_btUserInfo3.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,rcCreate,this,IDC_USER_INFO_3); m_btUserInfoSet.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,rcCreate,this,IDC_USER_INFO_SET); //设置按钮 HINSTANCE hInstance=AfxGetInstanceHandle(); m_btUserInfo1.SetButtonImage(IDB_BK_USER_INFO,TEXT("BT_USER_INFO_1"),hInstance,true,false); m_btUserInfo2.SetButtonImage(IDB_BK_USER_INFO,TEXT("BT_USER_INFO_2"),hInstance,true,false); m_btUserInfo3.SetButtonImage(IDB_BK_USER_INFO,TEXT("BT_USER_INFO_3"),hInstance,true,false); m_btUserInfoSet.SetButtonImage(IDB_BK_USER_INFO_SET,TEXT("BT_USER_INFO_SET"),hInstance,true,false); //移动窗口 CRect rcUserInfo; GetWindowRect(&rcUserInfo); SetWindowPos(NULL,0,0,rcUserInfo.Width(),ImageTitleM.GetHeight(),SWP_NOMOVE|SWP_NOZORDER); //提示控件 m_ToolTipCtrl.Create(this); m_ToolTipCtrl.Activate(TRUE); m_ToolTipCtrl.AddTool(&m_btUserInfo1,TEXT("上传头像")); m_ToolTipCtrl.AddTool(&m_btUserInfo2,TEXT("锁定本机")); m_ToolTipCtrl.AddTool(&m_btUserInfo3,TEXT("魅力兑换")); m_ToolTipCtrl.AddTool(&m_btUserInfoSet,TEXT("个人信息设置")); return 0; }
//绘画处理 bool CFrameEncircle::PreDrawEncircleImage(tagEncircleBMP & EncircleImage) { //加载图标 CBitImage ImageLogo; ImageLogo.LoadFromResource(AfxGetInstanceHandle(),TEXT("GAME_LOGO")); //绘画图标 if (ImageLogo.IsNull()==false) { //变量定义 CDC * pDC=CDC::FromHandle(EncircleImage.ImageTL.GetDC()); //绘画图标 ImageLogo.TransDrawImage(pDC,10,8,RGB(255,0,255)); //释放资源 EncircleImage.ImageTL.ReleaseDC(); } return true; }
// args: bitmap pointer, mode, unknown, unknown, unknown int __stdcall GppDraw( unsigned char* pImg, int mode, int unknown1, int unknown2, int unknown3 ) { switch( mode ) { case 0: image.setPixel( 1, 1, !image.getPixel( 1, 1 ) ); image.copyTo( pImg, 0 ); break; case 1: image.setPixel( 2, 2, !image.getPixel( 2, 2 ) ); image.copyTo( pImg, 1 ); break; case 2: image.setPixel( 3, 3, !image.getPixel( 3, 3 ) ); image.copyTo( pImg, 2 ); break; } return 0; }
//绘画背景 BOOL CWndUserInfoCtrl::OnEraseBkgnd(CDC * pDC) { //获取位置 CRect rcClient; GetClientRect(&rcClient); //建立缓冲 CImage ImageBuffer; ImageBuffer.Create(rcClient.Width(),rcClient.Height(),32); //创建 DC CImageDC BufferDC(ImageBuffer); CDC * pBufferDC=CDC::FromHandle(BufferDC); //变量定义 HINSTANCE hInstance=AfxGetInstanceHandle(); CSkinRenderManager * pSkinRenderManager=CSkinRenderManager::GetInstance(); //加载资源 CBitImage ImageTitleL; CBitImage ImageTitleM; CBitImage ImageTitleR; ImageTitleL.LoadFromResource(hInstance,IDB_USER_INFO_L); ImageTitleM.LoadFromResource(hInstance,IDB_USER_INFO_M); ImageTitleR.LoadFromResource(hInstance,IDB_USER_INFO_R); //渲染资源 pSkinRenderManager->RenderImage(ImageTitleL); pSkinRenderManager->RenderImage(ImageTitleM); pSkinRenderManager->RenderImage(ImageTitleR); //绘画背景 ImageTitleL.BitBlt(BufferDC,0,0); //填充中间 for (INT nXPos=ImageTitleL.GetWidth();nXPos<rcClient.Width();nXPos+=ImageTitleM.GetWidth()) { ImageTitleM.BitBlt(BufferDC,nXPos,0); } //绘画背景 ImageTitleR.BitBlt(BufferDC,rcClient.Width()-ImageTitleR.GetWidth(),0); //设置环境 pBufferDC->SetBkMode(TRANSPARENT); pBufferDC->SelectObject(CSkinResourceManager::GetInstance()->GetDefaultFont()); //用户信息 CGlobalUserInfo * pGlobalUserInfo=CGlobalUserInfo::GetInstance(); tagGlobalUserData * pGlobalUserData=pGlobalUserInfo->GetGlobalUserData(); //绘画用户 if (pGlobalUserData->dwUserID!=0L) { //绘画底框 if ((m_bHoverUnderWrite==true)||((m_EditUnderWrite.m_hWnd!=NULL)&&(m_EditUnderWrite.IsWindowVisible()==TRUE))) { //加载资源 CPngImage ImageUnderWriteL; CPngImage ImageUnderWriteM; CPngImage ImageUnderWriteR; ImageUnderWriteL.LoadImage(AfxGetInstanceHandle(),TEXT("UNDER_WRITE_L")); ImageUnderWriteM.LoadImage(AfxGetInstanceHandle(),TEXT("UNDER_WRITE_M")); ImageUnderWriteR.LoadImage(AfxGetInstanceHandle(),TEXT("UNDER_WRITE_R")); //绘画两边 ImageUnderWriteL.DrawImage(pBufferDC,m_rcUnderWrite.left,m_rcUnderWrite.top); ImageUnderWriteR.DrawImage(pBufferDC,m_rcUnderWrite.right-ImageUnderWriteR.GetWidth(),m_rcUnderWrite.top); //绘画中间 INT nXStart=m_rcUnderWrite.left+ImageUnderWriteL.GetWidth(); INT nXTerminate=m_rcUnderWrite.right-ImageUnderWriteR.GetWidth(); for (INT nXPos=nXStart;nXPos<nXTerminate;nXPos+=ImageUnderWriteM.GetWidth()) { ImageUnderWriteM.DrawImage(pBufferDC,nXPos,m_rcUnderWrite.top,__min(nXTerminate-nXPos,ImageUnderWriteM.GetWidth()),ImageUnderWriteM.GetHeight(),0,0); } } //绘画边框 if (m_bHoverFace==true) { theApp.m_FaceItemControlModule->DrawFaceItemFrame(pBufferDC,17,18,ITEM_FRAME_HOVER); } //绘画头像 if (pGlobalUserData->CustomFaceInfo.dwDataSize!=0) { DWORD * pdwCustomFace=pGlobalUserData->CustomFaceInfo.dwCustomFace; theApp.m_FaceItemControlModule->DrawFaceNormal(pBufferDC,16,17,pdwCustomFace); } else { theApp.m_FaceItemControlModule->DrawFaceNormal(pBufferDC,16,17,pGlobalUserData->wFaceID); } //绘画标题 pBufferDC->SetTextColor(RGB(0,0,0)); pBufferDC->TextOut(88,16,TEXT("昵 称:")); pBufferDC->TextOut(88,36,TEXT("奖 牌:")); pBufferDC->TextOut(88,56,TEXT("签 名:")); //构造奖牌 TCHAR szUserMedal[64]=TEXT(""); _sntprintf(szUserMedal,CountArray(szUserMedal),TEXT("%ld"),pGlobalUserData->dwUserMedal); //输出奖牌 CRect rcUserMedal; rcUserMedal.SetRect(130,36,rcClient.Width()-15,48); pBufferDC->DrawText(szUserMedal,lstrlen(szUserMedal),&rcUserMedal,DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); //输出帐号 CRect rcNickName; rcNickName.SetRect(130,16,rcClient.Width()-15,28); pBufferDC->DrawText(pGlobalUserData->szNickName,lstrlen(pGlobalUserData->szNickName),&rcNickName,DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); //变量定义 LPCTSTR pszUnderWrite=NULL; COLORREF crUnderWrite=RGB(0,0,0); //签名位置 CRect rcUnderWrite; rcUnderWrite.SetRect(130,56,rcClient.Width()-15,68); //常规状态 if ((m_EditUnderWrite.IsModifyStatus()==false)&&(pGlobalUserData->szUnderWrite[0]!=0)) { crUnderWrite=RGB(0,0,0); pszUnderWrite=pGlobalUserData->szUnderWrite; } //修改状态 if ((m_EditUnderWrite.IsModifyStatus()==true)&&(m_EditUnderWrite.m_szUnderWrite[0]!=0)) { crUnderWrite=RGB(100,100,100); pszUnderWrite=m_EditUnderWrite.m_szUnderWrite; } //提示状态 if (pszUnderWrite==NULL) { crUnderWrite=RGB(150,150,150); pszUnderWrite=TEXT("编辑个性签名"); } //输出签名 pBufferDC->SetTextColor(crUnderWrite); pBufferDC->DrawText(pszUnderWrite,lstrlen(pszUnderWrite),&rcUnderWrite,DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); } //绘画界面 pDC->BitBlt(0,0,rcClient.Width(),rcClient.Height(),pBufferDC,0,0,SRCCOPY); return TRUE; }
//绘画函数 VOID CSkinMenuKernel::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { //效验参数 ASSERT(lpDrawItemStruct->CtlType==ODT_MENU); if (lpDrawItemStruct->CtlType!=ODT_MENU) return; //变量定义 CRect rcItem=lpDrawItemStruct->rcItem; CDC * pDC=CDC::FromHandle(lpDrawItemStruct->hDC); CSkinMenuItem * pSkinMenuItem=(CSkinMenuItem *)lpDrawItemStruct->itemData; //自绘框架 if(m_bRemoveBorder==TRUE) { //区域偏移 rcItem.OffsetRect(FRAME_OUT_CX+FRAME_IN_CX,FRAME_OUT_CY+FRAME_IN_CY); //变量定义 CRect rcClient(0,0,0,0); GetClientRect(m_hWnd,rcClient); //绘制外框 pDC->FillSolidRect(0,0,rcClient.Width(),FRAME_OUT_CY,m_SkinAttribute.m_crOutFrame); pDC->FillSolidRect(rcClient.right-FRAME_OUT_CX,FRAME_OUT_CY,FRAME_OUT_CX,rcClient.Height()-FRAME_OUT_CY,m_SkinAttribute.m_crOutFrame); pDC->FillSolidRect(0,rcClient.Height()-FRAME_OUT_CY,rcClient.Width()-FRAME_OUT_CX,FRAME_OUT_CY,m_SkinAttribute.m_crOutFrame); pDC->FillSolidRect(0,FRAME_OUT_CY,FRAME_OUT_CX,rcClient.Height()-FRAME_OUT_CY,m_SkinAttribute.m_crOutFrame); //绘制内框 pDC->FillSolidRect(FRAME_OUT_CX,FRAME_OUT_CY,rcClient.Width()-2*FRAME_OUT_CX,FRAME_IN_CY,m_SkinAttribute.m_crInFrame); pDC->FillSolidRect(rcClient.right-FRAME_OUT_CX-FRAME_IN_CX,FRAME_OUT_CY,FRAME_IN_CX,rcClient.Height()-2*FRAME_OUT_CY,m_SkinAttribute.m_crInFrame); pDC->FillSolidRect(FRAME_OUT_CX,rcClient.Height()-FRAME_OUT_CY-FRAME_IN_CY,rcClient.Width()-2*FRAME_OUT_CX,FRAME_IN_CY,m_SkinAttribute.m_crInFrame); pDC->FillSolidRect(FRAME_OUT_CX,FRAME_OUT_CY,FRAME_IN_CX,rcClient.Height()-2*FRAME_OUT_CY,m_SkinAttribute.m_crInFrame); } //状态变量 bool bChecked=((lpDrawItemStruct->itemState&ODS_CHECKED)!=0); bool bSelected=((lpDrawItemStruct->itemState&ODS_SELECTED)!=0); bool bGrayed=((lpDrawItemStruct->itemState&ODS_DISABLED)||(lpDrawItemStruct->itemState&ODS_GRAYED)); //绘画背景 COLORREF crMenuBar=m_SkinAttribute.m_crMenuBar; COLORREF crBorder=m_SkinAttribute.m_crSelectBorder; COLORREF crNormalBack=m_SkinAttribute.m_crNormalBack; pDC->FillSolidRect(rcItem.left,rcItem.top,MENU_BAR_CX,rcItem.Height(),m_SkinAttribute.m_crMenuBar); pDC->FillSolidRect(rcItem.left+MENU_BAR_CX,rcItem.top,rcItem.Width()-MENU_BAR_CX,rcItem.Height(),m_SkinAttribute.m_crNormalBack); //焦点边框 if ((bSelected==true)&&(bGrayed==false)&&(pSkinMenuItem!=NULL)&&(pSkinMenuItem->m_MenuItemType!=MenuItemType_Separator)) { pDC->Draw3dRect(rcItem.left+1,rcItem.top+1,rcItem.Width()-2,rcItem.Height()-2,crBorder,crBorder); pDC->FillSolidRect(rcItem.left+2,rcItem.top+2,rcItem.Width()-4,rcItem.Height()-4,m_SkinAttribute.m_crSelectBack); } //选择标志 if (bChecked==true) { //加载资源 CBitImage ImageMenuFlags; ImageMenuFlags.LoadFromResource(GetModuleHandle(SKIN_CONTROL_DLL_NAME),IDB_SKIN_MENU_FLAGS); //渲染资源 CSkinRenderManager * pSkinRenderManager=CSkinRenderManager::GetInstance(); if (pSkinRenderManager!=NULL) pSkinRenderManager->RenderImage(ImageMenuFlags); //绘画界面 ImageMenuFlags.BitBlt(pDC->m_hDC,rcItem.left+1,rcItem.top+1,ImageMenuFlags.GetWidth()/2, ImageMenuFlags.GetHeight(),((bSelected==true)&&(bGrayed==false))?ImageMenuFlags.GetWidth()/2:0,0); } //其他菜单 if (pSkinMenuItem==NULL) { //获取信息 MENUITEMINFO MenuItemInfo; MenuItemInfo.cbSize=sizeof(MenuItemInfo); MenuItemInfo.fMask=MIIM_FTYPE|MIIM_BITMAP; GetMenuItemInfo(lpDrawItemStruct->itemID,&MenuItemInfo); return; } //界面菜单 switch (pSkinMenuItem->m_MenuItemType) { case MenuItemType_Image: //图形菜单 { //变量定义 CSkinMenuImage * pSkinMenuImage=(CSkinMenuImage *)pSkinMenuItem; //创建 DC CDC ImageDC; ImageDC.CreateCompatibleDC(pDC); ImageDC.SelectObject(pSkinMenuImage->m_hBitmap); //获取信息 BITMAP BitmapInfo; GetObject(pSkinMenuImage->m_hBitmap,sizeof(BitmapInfo),&BitmapInfo); //绘画位图 INT nYPos=rcItem.top+3; INT nXPos=rcItem.left+MENU_BAR_CX+SPACE_LEFT; pDC->BitBlt(nXPos,nYPos,BitmapInfo.bmWidth,BitmapInfo.bmHeight,&ImageDC,0,0,SRCCOPY); //释放 DC ImageDC.DeleteDC(); break; } case MenuItemType_String: //字符菜单 { //变量定义 CSkinMenuString * pSkinMenuString=(CSkinMenuString *)pSkinMenuItem; //设置颜色 pDC->SetBkMode(TRANSPARENT); pDC->SelectObject(CSkinResourceManager::GetInstance()->GetDefaultFont()); //设置颜色 if (bGrayed==true) pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT)); else if (bSelected==true) pDC->SetTextColor(m_SkinAttribute.m_crSelectText); else pDC->SetTextColor(m_SkinAttribute.m_crNormalText); //绘画字符 CRect rcString; rcString.top=rcItem.top; rcString.bottom=rcItem.bottom; rcString.right=rcItem.right-SPACE_RIGHT; rcString.left=rcItem.left+MENU_BAR_CX+SPACE_LEFT; pDC->DrawText(pSkinMenuString->m_strString,pSkinMenuString->m_strString.GetLength(),&rcString,DT_SINGLELINE|DT_VCENTER|DT_NOCLIP); break; } case MenuItemType_Separator: //拆分菜单 { //绘画拆分 pDC->FillSolidRect(rcItem.left+MENU_BAR_CX+SPACE_LEFT,rcItem.top+1,rcItem.Width()-MENU_BAR_CX-SPACE_LEFT-SPACE_RIGHT, rcItem.Height()-2,m_SkinAttribute.m_crSeparator); break; } } return; }
int Clear(lua_State *L) { image.clear(); return 0; }