当前位置: 首页>>代码示例>>C++>>正文


C++ Image::Attach方法代码示例

本文整理汇总了C++中Image::Attach方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::Attach方法的具体用法?C++ Image::Attach怎么用?C++ Image::Attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image的用法示例。


在下文中一共展示了Image::Attach方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetClientRect

void
ESChildSeatStatus::OnPaintClient(_DC *pDC, _Rect* pRectDC, _Rect* pRectClient){
	_Rect rcClient		= GetClientRect();
	_Rect rcControlDC	= ClientRectToDCRect(pRectDC, pRectClient, &rcClient);
	
	_Rect rcInvalid							= *pRectDC&rcControlDC;
	_Size szClient(rcClient.Width(), rcClient.Height());

	Image* pImageStatus						= m_pBgImage;
	Image* pImageStatusActive				= m_pBgActiveImage;
	Image* pImageStatusCurrent				= m_bActive ? pImageStatusActive : pImageStatus;

	ESChildControlTable*	pTable			= (ESChildControlTable*)GetParent();
	bool					bAllowCaching	= m_pOwner->IsDesignerMode() ? false : true;

	if( bAllowCaching ){
		HBITMAP hImageCached = pTable->GetCachedSeatStatusImage(m_bActive);
		BITMAP	bmInfo;
		memset(&bmInfo, 0, sizeof(BITMAP));
		if( hImageCached )
			GetObject(hImageCached, sizeof(BITMAP), &bmInfo);

		if( bmInfo.bmWidth != szClient.cx || bmInfo.bmHeight != szClient.cy ){
			// Update cached image.
			pTable->FreeCachedSeatStatusImage(m_bActive);
			hImageCached = NULL;
			if( pImageStatusCurrent->ScaleBitmap(ScaleMode::ScaleMode_Bilinier, szClient.cx, szClient.cy, _Rect(0, 0, szClient.cx, szClient.cy), hImageCached, (pImageStatusCurrent->GetBPP() == 32)) )
				pTable->UpdateCachedSeatStatusImage(m_bActive, hImageCached);
			}

		if( hImageCached ){
			// Use cached image.
			Image imgTemp;
			imgTemp.Attach(hImageCached);
			m_pOwner->DrawBackground(pDC, pRectDC, pRectClient, rcClient, FillMode::FillMode_CentredImage, RGB(0, 0, 0), &imgTemp, _Rect(0, 0, 0, 0), false, (int)ScaleMode::ScaleMode_Bilinier);
			imgTemp.Detach();
			}
		else{
			if( pImageStatusCurrent && !pImageStatusCurrent->IsNull() )
				m_pOwner->DrawBackground(pDC, pRectDC, pRectClient, rcClient, FillMode::FillMode_StretchImage, RGB(0, 0, 0), pImageStatusCurrent, m_rcOmitBorder, false, ScaleMode::ScaleMode_Bilinier);
			}
		}
	else{
		if( pImageStatusCurrent && !pImageStatusCurrent->IsNull() )
			m_pOwner->DrawBackground(pDC, pRectDC, pRectClient, rcClient, FillMode::FillMode_StretchImage, RGB(0, 0, 0), pImageStatusCurrent, m_rcOmitBorder, false, ScaleMode::ScaleMode_Bilinier);
		}

	ESChildControl::OnPaintClient(pDC, pRectDC, pRectClient);
	}
开发者ID:zqrtalent,项目名称:MercuryUI,代码行数:49,代码来源:ESChildSeatStatus.cpp

示例2: sizeof

BOOL
_DC::GetDibImageFromDC(int nBPP, Image& bmImage, UINT xSrc, UINT ySrc, UINT nWidth, UINT nHeight, _DC** pDCBitmap /*= NULL*/){
	if( !context_ ){
		ASSERT(FALSE);
		return FALSE;
		}

	HDC memDC = ::CreateCompatibleDC(NULL);

	BITMAPINFOHEADER bmpInfo32;
	memset(&bmpInfo32, 0, sizeof(BITMAPINFOHEADER));
	bmpInfo32.biBitCount    = nBPP;
	bmpInfo32.biCompression = BI_RGB;
	bmpInfo32.biPlanes      = 1;
	bmpInfo32.biHeight      = nHeight;
	bmpInfo32.biSize        = sizeof(BITMAPINFOHEADER);
	bmpInfo32.biWidth       = nWidth;
	
	void*   lpMap = NULL;
	HBITMAP hDib  = ::CreateDIBSection(memDC, (BITMAPINFO*)&bmpInfo32, DIB_RGB_COLORS, &lpMap, NULL, 0);
	if( !hDib ){
		::DeleteDC(memDC);
		return FALSE;
		}

	::SelectObject	(memDC, hDib);
	::BitBlt		(memDC, 0, 0, nWidth, nHeight, context_, xSrc, ySrc, SRCCOPY);

	if( pDCBitmap ){
		*pDCBitmap = new _DC();
		(*pDCBitmap)->Attach(memDC);
		}
	else{
		::DeleteDC(memDC);
		memDC = NULL;
		}

	bmImage.Attach(hDib);
	return TRUE;
	}
开发者ID:zqrtalent,项目名称:MercuryUI,代码行数:40,代码来源:PlatformDeviceContext_Win.cpp

示例3:

bool
ESChildAvatar::SetAvatarImage(Image* pImage, bool bRedraw){
	if( !pImage || pImage->IsNull() )
		return false;

	if( !m_pImageAvatarBg || m_pImageAvatarBg->IsNull() )
		return false;

	_Size	szAvatar(m_pImageAvatarBg->GetWidth(), m_pImageAvatarBg->GetHeight());
	Image bmAvatar;
	if( !bmAvatar.CreateDIBBitmap(32, RGB(0, 0, 0), szAvatar.cx, szAvatar.cy) )
		return false;

	ImageDef hDest = bmAvatar;
	if( !pImage->ScaleBitmap_Bilinier(szAvatar.cx, szAvatar.cy, _Rect(0, 0, szAvatar.cx, szAvatar.cy), hDest, (pImage->GetBPP() == 32), 255) ){
		bmAvatar.Destroy();
		return false;
		}

	Image imgBg;
	imgBg.Attach(bmAvatar.Detach());
	Image* pImgAvatar = Image::CombineImages(&imgBg, m_pImageAvatarBg, true);
	if( !pImgAvatar ){
		imgBg.Destroy();
		return false;
		}

	m_imageAvatar.Destroy();
	m_imageAvatar.Attach(pImgAvatar->Detach());
	m_pImageAvatar = &m_imageAvatar;
	imgBg.Destroy();
	delete pImgAvatar;

	if( bRedraw )
		Redraw();
	return true;

	}
开发者ID:zqrtalent,项目名称:MercuryUI,代码行数:38,代码来源:ESChildAvatar.cpp

示例4: GetTempImage

BOOL
_DC::GetSelectedDibImageFromDC(Image& imageDib){
	if( !context_ ){
		ASSERT(FALSE);
		return FALSE;
		}

	Image*		pTemp		= GetTempImage();
	ImageDef	hDibImage	= (HBITMAP)::SelectObject(context_, *pTemp);
	if( hDibImage != NULL ){
		BITMAP bmInfo;
		if( GetObject(hDibImage, sizeof(BITMAP), &bmInfo) == sizeof(BITMAP) && bmInfo.bmBits != NULL ){
			::SelectObject(context_, hDibImage);
			imageDib.Attach(hDibImage);
			return true;
			}
		else{
			::SelectObject(context_, hDibImage);
			hDibImage = NULL;
			}
		}
	return false;
	}
开发者ID:zqrtalent,项目名称:MercuryUI,代码行数:23,代码来源:PlatformDeviceContext_Win.cpp

示例5: EmbedeedFont


//.........这里部分代码省略.........
			int			nWidthLimit				= pImage->GetWidth();
			int			nWidth					= pImage->GetWidth();
			int			nHeight					= pImage->GetHeight();
			int			nWidthBytes				= pImage->GetWidthBytes();
			int			nSymbolCt				= 0;
			BYTE*		pBits					= (BYTE*)pImage->GetBits();
			int			nXOffset				= 0;
			int			nBPP					= pImage->GetBPP()/8;
			int			nSymbolMostLeftOffset	= -1;
			int			nSymbolMostRightOffset	= -1;
			CDWordArray arrSymbolLeftOffsetAndWidth;
			std::string	sSymbolStartPointAndWidth;

			int			nMaxXOffset				= nWidth;
			for(int x=nXOffset; x<nMaxXOffset; x++){
				bool bClearLine = true;
				for(int y=0; y<nHeight; y++){
					BYTE* pLineStartingBits = &pBits[((nHeight - y - 1)*nWidthBytes)];
					BYTE* pPixel			= &pLineStartingBits[x*nBPP];

					// Is pixel visible.
					if( pPixel[0] > 10 ){
						bClearLine = false;
						if( nSymbolMostLeftOffset > -1 )
							nSymbolMostRightOffset = x;
						else
							nSymbolMostLeftOffset = x;
						continue;
						}
		
					pPixel = &pPixel[nBPP];
					}

				if( bClearLine && nSymbolMostLeftOffset > -1 ){
					if( nSymbolMostRightOffset == -1 )
						nSymbolMostRightOffset = nSymbolMostLeftOffset;
					DWORD dwCombineVal = (nSymbolMostLeftOffset << 16) | ((nSymbolMostRightOffset - nSymbolMostLeftOffset + 1)&0xFFFF);
					arrSymbolLeftOffsetAndWidth.push_back(dwCombineVal);

#ifdef _DEBUG
					std::string sFormat;
					stringEx::Format(sFormat, _T("%d:%d;"), nSymbolMostLeftOffset, nSymbolMostRightOffset - nSymbolMostLeftOffset + 1);
					sSymbolStartPointAndWidth += sFormat;
#endif
					nSymbolMostLeftOffset	= -1;
					nSymbolMostRightOffset	= -1;
					}
				}

			pInfo->m_imageCharacters.Attach(pImage->Detach());
			delete pImage;

			if( (arrSymbolLeftOffsetAndWidth.size() == pFont->m_arrCharacters.GetCount()) ){
				pInfo->m_pCharPoints = new Point[arrSymbolLeftOffsetAndWidth.size()];
				for(int j=0; j<arrSymbolLeftOffsetAndWidth.size(); j++){
					DWORD dwCombineVal = arrSymbolLeftOffsetAndWidth.at(j);
					pInfo->m_pCharPoints[j].x = (int)(dwCombineVal>>16);
					pInfo->m_pCharPoints[j].y = (int)(dwCombineVal&0xFFFF);
					}
				}
			else{
#ifdef _DEBUG
				Image bmImg;
				bmImg.CreateDIBBitmap(pInfo->m_imageCharacters.GetBPP(), RGB(0, 0, 0), pInfo->m_imageCharacters.GetWidth(),
					pInfo->m_imageCharacters.GetHeight()*2, 0);

				_DC memDC;
				memDC.CreateCompatibleDC(NULL);
				memDC.SelectObject(bmImg);

				_DC srcDC;
				srcDC.CreateCompatibleDC(NULL);
				srcDC.SelectObject(pInfo->m_imageCharacters);
				memDC.BitBlt(0, 0, pInfo->m_imageCharacters.GetWidth(), pInfo->m_imageCharacters.GetHeight(), srcDC, 0, 0, SRCCOPY);

				int nHeight = pInfo->m_imageCharacters.GetHeight();
				for(int j=0; j<arrSymbolLeftOffsetAndWidth.size(); j++){
					DWORD dwCombineVal = arrSymbolLeftOffsetAndWidth.at(j);
					int nLeft = (int)(dwCombineVal>>16);
					int nWidth = (int)(dwCombineVal&0xFFFF);

					memDC.FillSolidRect(Rect(nLeft, nHeight, nLeft+nWidth, nHeight+nHeight), RGB(255, 255, 0));
					}

				DeleteFile((sDir + _T("__") + sName2).c_str());
				Image img;
				img.Attach((HBITMAP)bmImg.Detach());
//				img.Save(sDir + _T("__") + sName2);
				img.Destroy();
				
				std::string sMsg;
				stringEx::Format(sMsg, _T("Characters count is not the same for font '%s' item '%s'"), sFontName.c_str(), sName.c_str());
				MessageBox(NULL, sMsg.c_str(), _T("Error"), MB_OK);
#endif
				delete pInfo;
				continue;
				}

			pInfo->m_nCharCount = arrSymbolLeftOffsetAndWidth.size();
			}
开发者ID:zqrtalent,项目名称:MercuryUI,代码行数:101,代码来源:EmbedeedFontMan.cpp


注:本文中的Image::Attach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。