Ejemplo n.º 1
0
//-----------------------
/// イメージリストを初期化する
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 );
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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);
}
Ejemplo n.º 4
0
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;
    }
}
Ejemplo n.º 5
0
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;
}
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;
}
Ejemplo n.º 7
0
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);
}
Ejemplo n.º 8
0
// 读取图片(从文件读)
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;
}
Ejemplo n.º 9
0
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);
}
Ejemplo n.º 10
0
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;
}
Ejemplo n.º 11
0
/**
 * 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();
}
Ejemplo n.º 12
0
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;
}
Ejemplo n.º 13
0
/**
 *  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);
}
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(); 
}
Ejemplo n.º 15
0
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);
}
Ejemplo n.º 16
0
/**
 *  This function replaces srcColour in 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 srcColour    The colour to replace.
 *  @param dstColour    The colour to replace with.
 */
void
controls::replaceColour
(
    HBITMAP             hbitmap,
    COLORREF            srcColour,
    COLORREF            dstColour
)
{
    if (hbitmap == NULL)
        return;

    // This can almost be certainly sped up, but at the moment I only use it
    // on small images.
    CBitmap bitmap;
    bitmap.Attach(hbitmap);
    CDC dc;
    dc.CreateCompatibleDC(NULL);
    CBitmap *oldBMP = dc.SelectObject(&bitmap);
    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);
        }
    }
    bitmap.Detach();
    dc.SelectObject(oldBMP);
}
Ejemplo n.º 17
0
BOOL CDownloads_Deleted::Create(CWnd *pParent)
{
	CRect rc (0, 0, 0, 0);

	
	if (FALSE == CListCtrlEx::Create (LVS_REPORT|LVS_OWNERDRAWFIXED|LVS_SHOWSELALWAYS,
									  rc, pParent, 0x5A9))
		return FALSE;

	SetExtendedStyle (LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_INFOTIP);

	m_images.Create (16, 17, ILC_COLOR24 | ILC_MASK, 7, 1);
	CBitmap bmp;
	bmp.Attach (SBMP (IDB_DOWNLOADSTASKS));
	m_images.Add (&bmp, RGB (255, 0, 255));
	SetImageList (&m_images, LVSIL_SMALL);

	m_selimages.Create (16, 17, ILC_COLOR24 | ILC_MASK, 7, 1);
	CBitmap bmp2;
	bmp2.Attach (SBMP (IDB_DOWNLOADSTASKS_SEL));
	m_selimages.Add (&bmp2, RGB (255, 0, 255));
	SetSelectedImages (&m_selimages);

	InsertColumn (0, "", LVCFMT_LEFT, 200, 0);
	InsertColumn (1, "", LVCFMT_LEFT, 50, 0);
	InsertColumn (2, "", LVCFMT_LEFT, 100, 0);
	InsertColumn (3, "", LVCFMT_LEFT, 58, 0);
	InsertColumn (4, "", LVCFMT_LEFT, 200, 0);

	ReadState ("DownloadsDeleted");

	

	return TRUE;
}
Ejemplo n.º 18
0
BOOL CTrueColorToolBar::SetTrueColorToolBar(UINT uToolBarType, 
							     	        UINT uToolBar,
										    int  nBtnWidth)
{
	CImageList	cImageList;
	CBitmap		cBitmap;
	BITMAP		bmBitmap;
	
	if (!cBitmap.Attach(LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(uToolBar),
								  IMAGE_BITMAP, 0, 0,
								  LR_DEFAULTSIZE|LR_CREATEDIBSECTION)) ||
	    !cBitmap.GetBitmap(&bmBitmap))
		return FALSE;

	CSize		cSize(bmBitmap.bmWidth, bmBitmap.bmHeight); 
	int			nNbBtn	= cSize.cx/nBtnWidth;
	RGBTRIPLE*	rgb		= (RGBTRIPLE*)(bmBitmap.bmBits);
	COLORREF	rgbMask	= RGB(rgb[0].rgbtRed, rgb[0].rgbtGreen, rgb[0].rgbtBlue);
	
	if (!cImageList.Create(nBtnWidth, cSize.cy, ILC_COLOR24|ILC_MASK, nNbBtn, 0))
		return FALSE;
	
	if (cImageList.Add(&cBitmap, rgbMask) == -1)
		return FALSE;

	SendMessage(uToolBarType, 0, (LPARAM)cImageList.m_hImageList);
	cImageList.Detach(); 
	cBitmap.Detach();
	
	return TRUE;
}
Ejemplo n.º 19
0
xpr_bool_t LoadImgList(CImageList *aImgList, HBITMAP aBitmap, CSize aIconSize, xpr_sint_t aOverlayCount)
{
    if (XPR_IS_NULL(aImgList) || XPR_IS_NULL(aBitmap))
        return XPR_FALSE;

    CBitmap sBitmap;
    sBitmap.Attach(aBitmap);

    if (XPR_IS_NOT_NULL(aImgList))
    {
        if (aImgList->m_hImageList)
            aImgList->DeleteImageList();

        aImgList->Create(aIconSize.cx, aIconSize.cy, ILC_COLOR16 | ILC_MASK, -1, -1);
        aImgList->Add(&sBitmap, RGB(255,0,255));
    }

    sBitmap.DeleteObject();

    xpr_sint_t i;
    for (i = 0; i < aOverlayCount; ++i)
        aImgList->SetOverlayImage(i, i+1);

    return XPR_TRUE;
}
Ejemplo n.º 20
0
void CPropPageFrameDefault::SetCaption(LPCTSTR lpszCaption, HICON hIcon /*= NULL*/)
{
	CPropPageFrame::SetCaption(lpszCaption, hIcon);

	// build image list
	if (m_Images.GetSafeHandle())
		m_Images.DeleteImageList();
	if (hIcon)
	{
		ICONINFO	ii;
		if (!GetIconInfo(hIcon, &ii))
			return;

		CBitmap	bmMask;
		bmMask.Attach(ii.hbmMask);
		if (ii.hbmColor) DeleteObject(ii.hbmColor);

		BITMAP	bm;
		bmMask.GetBitmap(&bm);

		if (!m_Images.Create(bm.bmWidth, bm.bmHeight, ILC_COLOR32|ILC_MASK, 0, 1))
			return;

		if (m_Images.Add(hIcon) == -1)
			m_Images.DeleteImageList();
	}
}
Ejemplo n.º 21
0
void CDrawCommon::DrawBitmap(HBITMAP hbitmap, CPoint start_point, CSize size, StretchMode stretch_mode)
{
	CBitmap bitmap;
	if (!bitmap.Attach(hbitmap))
		return;
	DrawBitmap(bitmap, start_point, size, stretch_mode);
	bitmap.Detach();
}
Ejemplo n.º 22
0
BOOL CCardUseDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	// 카드세팅 //
	int i,j;

	for(i=0;i<27;i++) {
		for(j=0;j<cardn;j++)if(card[j]==i) break;
		if(j==cardn) card_inf[i]='0';
	}

	// MemDC 가상화면

	CDC *pDC=GetDC(),MemDC,MemDC2;
	CBitmap bitmap;
	char filename[50];
	int x=0,y=0;	

	MemDC.CreateCompatibleDC(pDC);
	MemDC2.CreateCompatibleDC(pDC);
	
	card_map.CreateCompatibleBitmap(pDC,900,450);
	CBitmap *pTempBitmap = (CBitmap *) MemDC.SelectObject(&card_map);
	CBitmap *pTempBitmap2;
	
	for(int n=0;n<27;n++) {
		strcpy(filename,"./images/card/dcard1.bmp");

		if(card_inf[n]!='0') filename[19] = card_inf[n];
		else filename[19]='x';

		HBITMAP hBitmap;

		hBitmap = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), (LPCTSTR)
		filename, IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE);
		
		bitmap.Attach(hBitmap);
		
		pTempBitmap2 = MemDC2.SelectObject(&bitmap);
		MemDC.BitBlt(x*100,y*150,100,150,&MemDC2,0,0,SRCCOPY);
		MemDC2.SelectObject(pTempBitmap2);
		bitmap.DeleteObject();

		if(++x>8) {
			x=0;
			y++;
		}
	}

	MemDC.SelectObject(pTempBitmap);
	MemDC2.DeleteDC();
	MemDC.DeleteDC();
	ReleaseDC(pDC);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 23
0
void CEx_DrawView::OnSaveAsBitmap() 
{
	// TODO: Add your command handler code here
	CFileDialog dlg(FALSE, _T(".bmp"), _T("图片1"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("位图(*.bmp)|*.bmp||"));
    if (dlg.DoModal() != IDOK)
    {
        return;
    }

    CFile file;
    file.Open(dlg.GetPathName(), CFile::modeWrite | CFile::modeCreate);

    CDC* pDC = GetDC();
    BITMAP bm;
//     pDC->GetCurrentBitmap()->GetBitmap(&bm); // 这个在XP下会失败
    CDC dc;
    CBitmap bitmap;
    dc.CreateCompatibleDC(pDC);
    BITMAPINFO biPicInfo;
    LPVOID pvBits = NULL;
    biPicInfo.bmiHeader.biSize          = sizeof(biPicInfo.bmiHeader);
    biPicInfo.bmiHeader.biWidth         = m_size.cx;
    biPicInfo.bmiHeader.biHeight        = m_size.cy;
    biPicInfo.bmiHeader.biPlanes        = 1;
    biPicInfo.bmiHeader.biBitCount      = 32;
    biPicInfo.bmiHeader.biCompression   = BI_RGB;      // = 0 不压缩
    biPicInfo.bmiHeader.biSizeImage     = (m_size.cx * biPicInfo.bmiHeader.biBitCount + 31) / 32 * 4 * m_size.cy;
    biPicInfo.bmiHeader.biXPelsPerMeter = 0;    //
    biPicInfo.bmiHeader.biYPelsPerMeter = 0;    //
    biPicInfo.bmiHeader.biClrUsed       = 0;    // use all
    biPicInfo.bmiHeader.biClrImportant  = 0;    // use all
    bitmap.Attach(CreateDIBSection(NULL, &biPicInfo, DIB_RGB_COLORS, &pvBits, NULL, 0));
    bitmap.GetBitmap(&bm);
    dc.SelectObject(&bitmap);
    dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, NULL, 0, 0, WHITENESS);
    DrawGraphic(&dc);
    ReleaseDC(pDC);

    DWORD size = bm.bmWidthBytes * bm.bmHeight;

    BITMAPFILEHEADER bf;
    bf.bfType = 0x4d42;
    bf.bfSize = size + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
    bf.bfReserved1 = 0;
    bf.bfReserved2 = 0;
    bf.bfOffBits = 0x36;

    LPVOID pBits = (LPVOID) GlobalAlloc(GMEM_ZEROINIT, size);
    CopyMemory(pBits, pvBits, size);

    file.Write(&bf, sizeof(BITMAPFILEHEADER));
    file.Write(&biPicInfo.bmiHeader, sizeof(BITMAPINFOHEADER));
    file.Write(pBits, size);
    
    GlobalFree(pBits);
}
Ejemplo n.º 24
0
CBitmap* OUAssetsTabDlg::ScaleBitmap(CImage* pImg, int maxwidth, int maxheight)
{
    /** 计算新大小和位置 */
    int nWidth = pImg->GetWidth();
    int nHeight = pImg->GetHeight();
    int nNewWidth = nWidth, nNewHeight = nHeight;
    int x, y;
    if(nWidth > maxwidth || nHeight > maxheight)
    {
        int nWidth1, nWidth2;
        int nHeight1, nHeight2;

        nWidth1 = maxwidth, nHeight1 = (float)(((float)maxwidth / (float)(nWidth)) * (float)nHeight);
        nHeight2 = maxheight, nWidth2 = (float)(((float)maxheight / (float)(nHeight)) * (float)nWidth);

        if(nHeight1 > maxheight) nNewWidth = nWidth2, nNewHeight = nHeight2;
        else
        if(nWidth2 > maxwidth) nNewWidth = nWidth1, nNewHeight = nHeight1;
        else
        {
            nNewWidth = max(nWidth1, nWidth2);
            nNewHeight = max(nHeight1, nHeight2);
        }
    }
    x = (maxwidth - nNewWidth) >> 1;
    y = (maxheight - nNewHeight) >> 1;

    CBitmap* pImgCpy = new CBitmap();
    pImgCpy->DeleteObject();
    pImgCpy->Attach(pImg->operator HBITMAP());

    CDC* pMDC1 = new CDC();
    CDC* pMDC2 = new CDC();
    CBitmap* pOldBt1;
    CBitmap* pOldBt2;
    CBitmap* pBmPtr = new CBitmap();
    CClientDC dc(this);

    pMDC2->CreateCompatibleDC(&dc);
    pOldBt2 = pMDC2->SelectObject(pImgCpy);

    pMDC1->CreateCompatibleDC(&dc);
    pBmPtr->CreateCompatibleBitmap(&dc, maxwidth, maxheight);
    pOldBt1 = pMDC1->SelectObject(pBmPtr);

    BITMAP bm;
    GetObject(*pImgCpy, sizeof(bm), &bm);
    pMDC1->StretchBlt(x, y, nNewWidth, nNewHeight, pMDC2, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);

    pMDC1->SelectObject(pOldBt1);
    pMDC1->DeleteDC();
    pMDC2->SelectObject(pOldBt2);
    pMDC2->DeleteDC();

    return pBmPtr;
}
Ejemplo n.º 25
0
    BOOL DrawBitmap(HDC hDC, LPCTSTR lpzBitmapFile, const RECT& dstRect, COLORREF clrTransColor)
    {
        HBITMAP hBitmap = (HBITMAP)LoadImageFromFile(lpzBitmapFile);
        if (hBitmap == NULL)
            return FALSE;

        CBitmap bmp;
        bmp.Attach(hBitmap);
        return DrawBitmap(hDC, hBitmap, dstRect, clrTransColor);
    }
Ejemplo n.º 26
0
void CAlphaIconsPage::ResampleImages()
{
	if (m_bResample)
	{
		CBitmap bmpResample;
		bmpResample.Attach(CXTPImageManager::ResampleAlphaLayer(IDR_ICONS_MENU_32, RGB(0, 0xFF, 0)));
		XTPImageManager()->SetIcons(IDR_ICONS_MENU_32, bmpResample);

		bmpResample.DeleteObject();
		bmpResample.Attach(CXTPImageManager::ResampleAlphaLayer(IDR_ICONS_TOOLBAR_32, RGB(0, 0xFF, 0)));
		XTPImageManager()->SetIcons(IDR_ICONS_TOOLBAR_32, bmpResample);
	} else
	{
		XTPImageManager()->SetIcons(IDR_ICONS_MENU_32);
		XTPImageManager()->SetIcons(IDR_ICONS_TOOLBAR_32);
	}

	RedrawCommandBars();

}
Ejemplo n.º 27
0
/**
 * add runtime toolbar.
 *
 * @param           [in] pToolbarData: pointer to toolbar data
 *                       create pToolbarData with new before calling this function.
 *                       it will be stored and deleted within this class so don't
 *                       call delete yourself.
 * @return          successful?
*/
BOOL CCoolMenuManager::AddRuntimeToolbar(CToolbarData* pToolbarData)
{
    CString strBitmapFile;

    ASSERT(pToolbarData);

	int iNextImage = m_ilButtons.GetImageCount();
    int iNumButtons = pToolbarData->m_ItemIdArray.GetSize();
    int iNumButtonFiles = pToolbarData->m_astrBitmapFileName.GetSize();

    ASSERT(iNumButtons == iNumButtonFiles);

    UINT nID;
    for(int iButton=0; iButton < iNumButtons; ++iButton)
    {
        HBITMAP hbmpButton;
        CBitmap bmButton;

        strBitmapFile = pToolbarData->m_astrBitmapFileName[iButton];
        if(strBitmapFile.IsEmpty())
        {
            continue;
        }
        hbmpButton = (HBITMAP)::LoadImage(0, strBitmapFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
        if(hbmpButton)
        {
            bmButton.Attach(hbmpButton);
        	m_ilButtons.Add(&bmButton, pToolbarData->m_bgColor);

		    nID = pToolbarData->m_ItemIdArray[iButton];
		    if (nID > 0)
            {
			    if (GetButtonIndex(nID) >= 0) 
                {
				    TRACE(_T("*** Duplicate button ID %d ignored\n"), nID);
			    }
                else
                {
				    m_mapIDtoImage.SetAt(nID, (void*)iNextImage++);
                }
            }
		}
        else
        {
            TRACE("AddRuntimeToolbar(): bitmap %s could not be loaded\n", strBitmapFile);
        }
	}
	m_arToolbarID.Add(pToolbarData->m_uiID);  // remember toolbar ID for Refresh
    
    // store toolbar data
    m_tToolbarDataList.AddTail(pToolbarData);

	return TRUE; // success!
}
Ejemplo n.º 28
0
BOOL CXTPPopupItem::SetIcons(HBITMAP hBitmap, COLORREF clrTransparent, int itemIcon, BOOL bAlphaBitmap)
{
    BITMAP bmpInfo;
    ZeroMemory(&bmpInfo, sizeof(BITMAP));
    ::GetObject(hBitmap, sizeof(BITMAP), &bmpInfo);

    int nCount = (itemIcon & xtpPopupItemIconNormal ? 1 : 0) +
                 (itemIcon & xtpPopupItemIconSelected ? 1 : 0) +
                 (itemIcon & xtpPopupItemIconPressed ? 1 : 0);

    if (nCount == 0)
        return FALSE;

    int nIndex = 0;

    CBitmap bmp;
    bmp.Attach(hBitmap);


    COLORREF clr = m_pControl->GetImageManager()->GetMaskColor();
    m_pControl->GetImageManager()->SetMaskColor(clrTransparent);

    if ((itemIcon & xtpPopupItemIconNormal) != 0)
    {
        UINT nIDs[] = {IMAGE_PLACEHOLDER, IMAGE_PLACEHOLDER, IMAGE_PLACEHOLDER};
        nIDs[nIndex++] = GetIconIndex();

        m_pControl->GetImageManager()->SetIcons(bmp, nIDs, nCount, CSize(bmpInfo.bmWidth / nCount, bmpInfo.bmHeight), xtpImageNormal, bAlphaBitmap);
    }

    if ((itemIcon & xtpPopupItemIconSelected) != 0)
    {
        UINT nIDs[] = {IMAGE_PLACEHOLDER, IMAGE_PLACEHOLDER, IMAGE_PLACEHOLDER};
        nIDs[nIndex++] = GetIconIndex();

        m_pControl->GetImageManager()->SetIcons(bmp, nIDs, nCount, CSize(bmpInfo.bmWidth / nCount, bmpInfo.bmHeight), xtpImageHot, bAlphaBitmap);
    }

    if ((itemIcon & xtpPopupItemIconPressed) != 0)
    {
        UINT nIDs[] = {IMAGE_PLACEHOLDER, IMAGE_PLACEHOLDER, IMAGE_PLACEHOLDER};
        nIDs[nIndex++] = GetIconIndex();

        m_pControl->GetImageManager()->SetIcons(bmp, nIDs, nCount, CSize(bmpInfo.bmWidth / nCount, bmpInfo.bmHeight), xtpImageChecked, bAlphaBitmap);
    }


    m_pControl->GetImageManager()->SetMaskColor(clr);

    bmp.Detach();


    return TRUE;
}
Ejemplo n.º 29
0
void KDrawFrame::LoadBmp(CBitmap& bmp, LPCWSTR strFile)
{
	HBITMAP handle = (HBITMAP)::LoadImage( _AtlBaseModule.GetResourceInstance(),
		strFile, IMAGE_BITMAP, 
		0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
	if (handle)
	{
		bmp.Attach(handle);
	}
	return;
}
Ejemplo n.º 30
0
// 读取图片(从资源读)
BOOL LoadBitmapFromIDResource(UINT nID, CBitmap &bitmap, CSize &size, CString strType)
{
	HINSTANCE hInst = AfxGetResourceHandle();  
	HRSRC hRsrc = ::FindResource (hInst,MAKEINTRESOURCE(nID), strType);
	if (!hRsrc)  
	{
		return FALSE; 
	}

	DWORD len = SizeofResource(hInst, hRsrc);  
	BYTE* lpRsrc = (BYTE*)LoadResource(hInst, hRsrc);  
	if (!lpRsrc)  
	{
		return FALSE;
	}
	HGLOBAL m_hMem = GlobalAlloc(GMEM_FIXED, len);  
	BYTE* pmem = (BYTE*)GlobalLock(m_hMem);  
	memcpy(pmem,lpRsrc,len);  
	IStream* pstm;  
	CreateStreamOnHGlobal(m_hMem,FALSE,&pstm);  
	Bitmap* pBitmap = Gdiplus::Bitmap::FromStream(pstm);  
	GlobalUnlock(m_hMem);  
	GlobalFree(m_hMem);
	pstm->Release();  
	FreeResource(lpRsrc); 

	HBITMAP hBitmap = NULL;
	Status status = pBitmap->GetLastStatus();
	if(Ok == status)
	{		
		status = pBitmap->GetHBITMAP(Color(0,0,0), &hBitmap);
		delete pBitmap;

		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;				

			return TRUE;
		}
	}

	return FALSE;
}