本文整理汇总了C++中Image::Detach方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::Detach方法的具体用法?C++ Image::Detach怎么用?C++ Image::Detach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::Detach方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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;
}
示例2: 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);
}
示例3: 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();
}