本文整理汇总了C++中CBitmap::Attach方法的典型用法代码示例。如果您正苦于以下问题:C++ CBitmap::Attach方法的具体用法?C++ CBitmap::Attach怎么用?C++ CBitmap::Attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBitmap
的用法示例。
在下文中一共展示了CBitmap::Attach方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AtlLoadBitmapImage
//-----------------------
/// イメージリストを初期化する
void CToolBarPropertyPage::_InitImageList()
{
if (m_imgList.m_hImageList)
m_imgList.Destroy();
CBitmap bmp;
bmp.Attach( AtlLoadBitmapImage(GetSmallFilePath().GetBuffer(0), LR_LOADFROMFILE) );
if (bmp.IsNull()) {
//bBig = FALSE; //+++ small用の表示がバグってるぽいので、とりあえずbig扱いで対処.
bmp.Attach( AtlLoadBitmapImage(GetBigFilePath().GetBuffer(0), LR_LOADFROMFILE) );
if (bmp.IsNull()) { //+++ 内蔵のbmpを使うようにする...
bmp.LoadBitmap(IDB_MAINFRAME_TOOLBAR_HOT); //+++ 内蔵のbmpを使うようにする...
if (bmp.IsNull()) {
/* ::MessageBox(m_hWnd, _T("ツールバースキンファイルが見つかりませんでした。\n")
_T("カスタマイズに支障が出るので操作ができないようになっています。\n")
_T("スキンフォルダにBigHot.bmpファイルを準備してください。") , _T("information"), MB_OK);*/
ATLASSERT(FALSE);
return;
}
}
}
bmp.GetSize(m_iconSize);
int nCount = m_iconSize.cx / m_iconSize.cy;
m_iconSize.cx = m_iconSize.cy;
MTLVERIFY( m_imgList.Create(m_iconSize.cx, m_iconSize.cy, ILC_COLOR24 | ILC_MASK, nCount, 1) );
MTLVERIFY( m_imgList.Add( bmp, RGB(255, 0, 255) ) != -1 );
}
示例2: AddImageList
int CShoshTreeCtrl::AddImageList(const char* stfilePath)
{
bool bRet= m_xImage->Load(stfilePath,CXIMAGE_FORMAT_PNG);
CDC *pDC = GetDC();
Bitmap * pbmp = GetNewBitmap(stfilePath);
if (pbmp == NULL) return -1;
m_pBitMapList2.push_back(pbmp);
Color cr = Color::White;
HBITMAP hBitmap = NULL ;//m_xImage->MakeBitmap(pDC->GetSafeHdc());
pbmp->GetHBITMAP( cr, &hBitmap );
if ( NULL != hBitmap )
{
CBitmap* pBitmap;
pBitmap = new CBitmap;
m_pBitMapList.push_back(pBitmap);
pBitmap->Attach(hBitmap);
int nRetNum = m_ImageList.Add(pBitmap,RGB(0,0,0));
return nRetNum;
}
return -1;
}
示例3: SaveAsImage
void CXTPChartControl::SaveAsImage(LPCTSTR lpszFilePath, CSize szBounds)
{
CBitmap bmp;
bmp.Attach(CXTPImageManager::Create32BPPDIBSection(0, szBounds.cx, szBounds.cy, 0));
{
CDC dc;
dc.CreateCompatibleDC(NULL);
CBitmap* pOldBitmap = dc.SelectObject(&bmp);
CRect rc(0, 0, szBounds.cx, szBounds.cy);
CXTPChartDeviceContext* pDC = m_pContent->CreateDeviceContext(this, dc, rc, FALSE);
if (pDC)
{
m_pContent->DrawContent(pDC, rc);
delete pDC;
}
dc.SelectObject(pOldBitmap);
}
CXTPChartDeviceContext::SaveToFile((HBITMAP)bmp.GetSafeHandle(), lpszFilePath);
}
示例4: _PrepareViewCommands
void CQuickScripts::_PrepareViewCommands(int iIndex, const ViewResource &view, int nLoop, int nCel)
{
ASSERT(iIndex < 10);
UINT nID = ID_GOTOVIEW1 + iIndex;
_viewNumbers[iIndex] = view.GetResourceNumber();
// Ensure we have a command entry for this.
CExtCmdItem *pCmdItem;
pCmdItem = g_CmdManager->CmdGetPtr(theApp._pszCommandProfile, nID);
if (pCmdItem == NULL)
{
pCmdItem = g_CmdManager->CmdAllocPtr(theApp._pszCommandProfile, nID);
}
// Update the command entry with an icon and text
if (pCmdItem)
{
CBitmap bitmap;
// Note: if the index is out of bounds, it will return a NULL HBITMAP
bitmap.Attach(view.GetBitmap(MAKE_INDEX(nLoop, nCel), 24, 24));
if ((HBITMAP)bitmap == NULL)
{
// Load an all black bitmap, to indicate the loop/cel are invalid.
bitmap.LoadBitmap(IDB_BITMAPNULL);
}
CExtBitmap extBitmap;
extBitmap.FromBitmap((HBITMAP)bitmap);
g_CmdManager->CmdSetIcon(theApp._pszCommandProfile, nID, extBitmap, RGB(255, 255, 255), CRect(0, 0, 24, 24));
std::string name = theApp.GetResourceMap().FigureOutName(RS_VIEW, view.GetResourceNumber());
pCmdItem->m_sMenuText = name.c_str();
pCmdItem->m_sTipTool = pCmdItem->m_sMenuText;
}
}
示例5: OnInitDialog
BOOL CPreferencesDlg::OnInitDialog()
{
ASSERT( !m_bSaveIniFile );
BOOL bResult = CTreePropSheet::OnInitDialog();
InitWindowStyles(this);
for (int i = 0; i < m_pages.GetSize(); i++)
{
if (GetPage(i)->m_psp.pszTemplate == m_pPshStartPage)
{
SetActivePage(i);
break;
}
}
//Xman Preferences Banner
CBitmap bmp;
VERIFY( bmp.Attach(theApp.LoadImage(_T("BANNER"), _T("JPG"))) );
if (bmp.GetSafeHandle())
{
m_banner.SetTexture((HBITMAP)bmp.Detach());
m_banner.SetFillFlag(KCSB_FILL_TEXTURE);
m_banner.SetSize(75);
m_banner.SetTitle(_T(""));
m_banner.SetCaption(_T(""));
m_banner.Attach(this, KCSB_ATTACH_RIGHT);
}
//Xman end
Localize();
return bResult;
}
示例6: Create
BOOL CWndLog::Create(CWnd *pParent)
{
CRect rc (0, 0, 50, 50);
if (FALSE == CListCtrl::Create (LVS_REPORT|LVS_NOSORTHEADER|LVS_SHOWSELALWAYS|LVS_OWNERDRAWFIXED, rc, pParent, 0x76329))
return FALSE;
SetExtendedStyle (LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP);
m_images.Create (16, 15, ILC_COLOR24 | ILC_MASK, 6, 1);
CBitmap bmp;
bmp.Attach (SBMP (IDB_LOGSTATES));
m_images.Add (&bmp, RGB (255, 0, 255));
SetImageList (&m_images, LVSIL_SMALL);
InsertColumn (0, "Time", LVCFMT_LEFT, 80, 0);
InsertColumn (1, "Date", LVCFMT_LEFT, 100, 0);
InsertColumn (2, "Information", LVCFMT_LEFT, 400, 0);
ShowWindow (SW_SHOW);
return TRUE;
}
示例7: AddString
int CTDLLanguageComboBox::AddString(LPCTSTR szLanguage, HBITMAP hbmFlag, DWORD dwItemData)
{
// create and associate the image list first time around
if (m_il.GetSafeHandle() == NULL)
{
m_il.Create(16, 11, ILC_COLOR32 | ILC_MASK, 1, 1);
SetImageList(&m_il);
}
COMBOBOXEXITEM cbe;
cbe.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT | CBEIF_LPARAM;
cbe.iItem = GetCount();
cbe.pszText = (LPTSTR)szLanguage;
cbe.lParam = dwItemData;
cbe.iImage = cbe.iSelectedImage = GetCount();
if (hbmFlag == NULL)
hbmFlag = CEnBitmap::LoadImageResource(IDR_YOURLANG_FLAG, _T("GIF"));
CBitmap tmp;
tmp.Attach(hbmFlag); // will auto cleanup
m_il.Add(&tmp, (COLORREF)-1);
return InsertItem(&cbe);
}
示例8: LoadBitmapFromFile
// 读取图片(从文件读)
BOOL LoadBitmapFromFile(const CString strPathFile, CBitmap &bitmap, CSize &size)
{
HBITMAP hBitmap = NULL;
#ifdef _UNICODE
Bitmap* pBitmap = Bitmap::FromFile(strPathFile);
#else
Bitmap* pBitmap = Bitmap::FromFile(CEncodingUtil::AnsiToUnicode(strPathFile));
#endif
Status status = pBitmap->GetLastStatus();
if(Ok == status)
{
status = pBitmap->GetHBITMAP(Color(0,0,0), &hBitmap);
if(Ok == status)
{
if(bitmap.m_hObject != NULL)
{
bitmap.Detach();
}
bitmap.Attach(hBitmap);
BITMAP bmInfo;
::GetObject( bitmap.m_hObject, sizeof(BITMAP), &bmInfo );
size.cx = bmInfo.bmWidth;
size.cy = bmInfo.bmHeight;
delete pBitmap;
return TRUE;
}
}
return FALSE;
}
示例9: LoadImage
void CbehaviorView::LoadImage()
{
HBITMAP hBitmap;
CString filename;
CString BMPFolder;
CString str;
CImage layerPng;
//str.Format("layer (%d).png", layernum);
//filename = BMPFolder + "\\" + str;
filename = "D:\\fish_editor\\mini_hammer-master\\workplace\\media\\fish_base\\plist\\8goldItem.png";
layerPng.Load(filename);
hBitmap=layerPng.Detach();
CBitmap bmp;
BITMAP l_bitMap;
bmp.Attach(hBitmap);
bmp.GetBitmap(&l_bitMap);
int height = l_bitMap.bmHeight;
int width = l_bitMap.bmWidth;
bmp.GetBitmapBits(128 * 128 * 4, m_lpBuf);
}
示例10: OnSendFileBmp
LRESULT CFolderListCtrl::OnSendFileBmp( WPARAM wParam, LPARAM lParam )
{
FPTFileBmp * pImgInfo = reinterpret_cast<FPTFileBmp*>(lParam);
LVFINDINFO lvFI;
int nItem;
if( !pImgInfo )
return 0;
bSetBmp = true;
lvFI.flags = LVFI_PARAM;
lvFI.lParam = pImgInfo->m_nItemID;
nItem = FindItem( &lvFI );
if( nItem != -1 )
{
CFLCItemData * pData = reinterpret_cast<CFLCItemData*>(GetItemData( nItem ));
if( !pData->m_bProcessed && pData->m_sFilePath == pImgInfo->m_sFilePath )
{
if( pImgInfo->m_nRetCode == FDE_OK && m_pimlThumbnails )
{
CBitmap bmp;
bmp.Attach( pImgInfo->m_hBmp );
int nPos = m_pimlThumbnails->Add( &bmp, RGB( 0, 0, 0 ) );
bmp.Detach();
if( nPos >= 0 )
{
pData->m_bProcessed = true;
pData->m_nThumbnailInd = nPos;
if( m_flvtViewType == flvtThumbnail )
SetValidItemImage( nItem );
}
}
pData->m_bProcessed = true;
m_nImageBalance--;
if( AfxGetMainWnd() )
static_cast<CScadViewerFrame*>(AfxGetMainWnd())->GetStatusBar().IncFilePos();
}
}
if( pImgInfo->m_hBmp )
::DeleteObject( pImgInfo->m_hBmp );
delete pImgInfo;
#ifdef SHOW_FILL_TIME
if (m_nImageBalance==0)
{
CSCADViewerStatBar &theStatusBar = ((CScadViewerFrame*)AfxGetMainWnd())->GetStatusBar();
theStatusBar.SetGenInfo(Timer.StopStr());
}
#endif
bSetBmp = false;
return 1;
}
示例11: LoadBitmap
/**
* Loads a bmp file.
*/
void CPreviewRect::LoadBitmap(const CString& Path)
{
// reset first
Reset(FALSE);
CBitmap* attempt = new CBitmap;
HBITMAP hbmp = (HBITMAP)LoadImage(0, Path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
if (hbmp && attempt->Attach(hbmp))
{
m_bitmap = attempt;
// take ownership
m_borrowed = false;
CRect client;
GetClientRect(&client);
// zoom to client rect
m_visible = doZoomBitmap(m_bitmap, client);
}
else
{
delete attempt;
}
// show image
doRequestGraphicalUpdate();
}
示例12: OnDraw
void CViewSockImage::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// 這邊畫 圖片
/////////////////////////////////////////////////////////////////////
CRect RectImage;
GetClientRect( &RectImage );
if(m_pBitmap != NULL)
{
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;
}
}
//
m_pBitmap = NULL;
}
示例13: replaceColour
/**
* This function replaces the colour in the top-left pixel of the bitmap with
* dstColour. It only works with 8bpp, 24bpp and 32bpp images. It has only
* been tested with 8bpp images.
*
* @param hbitmap The bitmap to change.
* @param dstColour The colour to replace with.
*/
void
controls::replaceColour
(
HBITMAP hbitmap,
COLORREF dstColour
)
{
if (hbitmap == NULL)
return;
CBitmap bitmap;
bitmap.Attach(hbitmap);
CDC dc;
dc.CreateCompatibleDC(NULL);
CBitmap *oldBMP = dc.SelectObject(&bitmap);
COLORREF srcColour = dc.GetPixel(0, 0);
BITMAP bitmapInfo;
bitmap.GetBitmap(&bitmapInfo);
for (int y = 0; y < bitmapInfo.bmHeight; ++y)
{
for (int x = 0; x < bitmapInfo.bmWidth; ++x)
{
COLORREF thisPixel = dc.GetPixel(x, y);
if (thisPixel == srcColour)
dc.SetPixel(x, y, dstColour);
}
}
dc.SelectObject(oldBMP);
bitmap.Detach();
replaceColour(hbitmap, srcColour, dstColour);
}
示例14: OnLoadPNG
void CVideoClientDlg::OnLoadPNG(LPCTSTR Path, CRect m_Rect)
{
ATL::CImage img;
HRESULT ret = img.Load(Path); //要加载的图片名称,包含路径
HBITMAP hbitmap = img.Detach();
//像操作 BMP 图片一样处理图片 ,下面是显示图片的操作
CPaintDC dc(this);// 用于绘制的设备上下文
CRect rect;
GetClientRect(&rect);
CBitmap pngBackground;
BITMAP bitmap;
CDC memdc;
pngBackground.Attach(hbitmap);
memdc.CreateCompatibleDC(&dc);
pngBackground.GetBitmap(&bitmap); //建立绑定关系
CBitmap *pbmpOld=memdc.SelectObject(&pngBackground); //保存原有CDC对象,并选入新CDC对象入DC
dc.SetStretchBltMode(COLORONCOLOR);//防止bmp图片失真
dc.StretchBlt(0,0,rect.Width(),rect.Height(),&memdc,0,0,bitmap.bmWidth,bitmap.bmHeight,SRCCOPY);
memdc.SelectObject(pbmpOld);
//程治谦 2015-1-13 防止内存泄漏
(*pbmpOld).DeleteObject();
DeleteObject(hbitmap);
img.Destroy();
pngBackground.DeleteObject();
memdc.DeleteDC();
}
示例15: fDisableImgListRemap
CPlayerToolBar::CPlayerToolBar()
: fDisableImgListRemap(false)
, m_pButtonsImages(NULL)
, m_hDXVAIcon(NULL)
{
HBITMAP hBmp = CMPCPngImage::LoadExternalImage(L"gpu", IDB_DXVA_ON, IMG_TYPE::UNDEF);
BITMAP bm = { 0 };
::GetObject(hBmp, sizeof(bm), &bm);
if (CMPCPngImage::FileExists(CString(L"gpu")) && (bm.bmHeight > 32 || bm.bmWidth > 32)) {
hBmp = CMPCPngImage::LoadExternalImage(L"", IDB_DXVA_ON, IMG_TYPE::UNDEF);
::GetObject(hBmp, sizeof(bm), &bm);
}
if (bm.bmWidth <= 32 && bm.bmHeight <= 32) {
CBitmap *bmp = DNew CBitmap();
bmp->Attach(hBmp);
CImageList *pButtonDXVA = DNew CImageList();
pButtonDXVA->Create(bm.bmWidth, bm.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0);
pButtonDXVA->Add(bmp, static_cast<CBitmap*>(NULL));
m_hDXVAIcon = pButtonDXVA->ExtractIcon(0);
delete pButtonDXVA;
delete bmp;
}
iDXVAIconHeight = bm.bmHeight;
iDXVAIconWidth = bm.bmWidth;
DeleteObject(hBmp);
}