Example #1
0
//IDB_BITMAP1,IDB_BITMAP2,IDB_BITMAP3,IDB_BITMAP1);//_
void CSkinBtn::SetImage(CString strNormal, CString strHover, CString strDown, CString strDisable)
{
	HBITMAP hBitmapNormal,hBitmapHover,hBitmapDown,hBitmapDisable;
	hBitmapNormal=HBITMAP(::LoadImage(AfxGetInstanceHandle(),strNormal,
		IMAGE_BITMAP,0,0,LR_LOADFROMFILE));
	hBitmapHover=HBITMAP(::LoadImage(AfxGetInstanceHandle(),strHover,
		IMAGE_BITMAP,0,0,LR_LOADFROMFILE));
	hBitmapDown=HBITMAP(::LoadImage(AfxGetInstanceHandle(),strDown,
		IMAGE_BITMAP,0,0,LR_LOADFROMFILE));
	hBitmapDisable=HBITMAP(::LoadImage(AfxGetInstanceHandle(),strDisable,
		IMAGE_BITMAP,0,0,LR_LOADFROMFILE));
    this->SetImage(hBitmapNormal,hBitmapHover,hBitmapDown,hBitmapDisable);
}
Example #2
0
void CSysColStatic::ReloadBitmap(int nImageID)
{
  if (nImageID != -1)
    m_nImageID = nImageID;

  if (m_nImageID == -1)
    return;

  // Need to convert the background colour to the user's
  // selected dialog colour.
  const COLORREF cr = GetSysColor(COLOR_3DFACE);
  const COLORREF cr192 = RGB(192, 192, 192);

  if (!m_imt.IsNull())
    m_imt.Detach();

  m_imt.LoadFromResource(AfxGetInstanceHandle(), m_nImageID);

  // Need to handle images with <= 8bpp (colour tables) and
  // those with higher colour information
  const int noOfCTableEntries = m_imt.GetMaxColorTableEntries();
  if (noOfCTableEntries > 0) {
    RGBQUAD *ctable = new RGBQUAD[noOfCTableEntries]; 
    m_imt.GetColorTable(0, noOfCTableEntries, ctable);

    for (int ic = 0; ic < noOfCTableEntries; ic++) {
      if (ctable[ic].rgbBlue  == 192 &&
          ctable[ic].rgbGreen == 192 &&
          ctable[ic].rgbRed   == 192) {
        ctable[ic].rgbBlue  = GetBValue(cr);
        ctable[ic].rgbGreen = GetGValue(cr);
        ctable[ic].rgbRed   = GetRValue(cr);
        break;
      }
    }
    m_imt.SetColorTable(0, noOfCTableEntries, ctable);
    delete[] ctable;
  } else {
    for (int x = 0; x < m_imt.GetWidth(); x++) {
      for (int y = 0; y < m_imt.GetHeight(); y++) {
        if (m_imt.GetPixel(x, y) == cr192)
          m_imt.SetPixel(x, y, cr);
      }
    }
  }

  HBITMAP hBmpOld = SetBitmap(HBITMAP(m_imt));
  ::DeleteObject(hBmpOld);
  ::DeleteObject(m_hBmp);
  m_hBmp = HBITMAP(m_imt);
}
Example #3
0
Button::Button(UINT_PTR subClassId, HINSTANCE hInst, HWND parent, int x, int y, int width, int height, int id,
               LPCWSTR text, DWORD additionalStyles) : Control(subClassId, hInst, parent, x, y, width, height, text,
                           WC_BUTTON, NULL, WS_CHILD | WS_VISIBLE | BS_CENTER | BS_VCENTER | BS_PUSHBUTTON | BS_TEXT | additionalStyles,
                           HMENU(id))
{
    DrawButtonDC = CreateCompatibleDC(nullptr);
    ClearButtonDC = CreateCompatibleDC(nullptr);
    HBITMAP bitmap = HBITMAP(LoadImage(Instance, MAKEINTRESOURCE(IDB_DRAW), IMAGE_BITMAP,
                                       PIC_SIZE, PIC_SIZE, LR_DEFAULTCOLOR));
    SelectObject(DrawButtonDC, bitmap);
    bitmap = HBITMAP(LoadImage(Instance, MAKEINTRESOURCE(IDB_CLEAR), IMAGE_BITMAP,
                               PIC_SIZE, PIC_SIZE, LR_DEFAULTCOLOR));
    SelectObject(ClearButtonDC, bitmap);
}
Example #4
0
LPLISTVIEW_PARAM InitializeListViewInstance(HWND hwnd)
{
	LPLISTVIEW_PARAM lv = new LISTVIEW_PARAM;
	
	lv->fIsListView = TRUE;
	lv->pfnWndProc = pfnLvProc;
	lv->hDesktopDC = GetDC(NULL);
	lv->hDC = CreateCompatibleDC(lv->hDesktopDC);

	SIZE sz = { GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) };

	ULONG uSize = sz.cx * sz.cy * sizeof(WRGBQUAD);
	BITMAPINFO bmi = { 0 };
	bmi.bmiHeader.biSize = sizeof(bmi);
	bmi.bmiHeader.biWidth = sz.cx;
	bmi.bmiHeader.biHeight = -sz.cy;
	bmi.bmiHeader.biPlanes = 1;
	bmi.bmiHeader.biBitCount = 32;
	bmi.bmiHeader.biCompression = BI_RGB;
	bmi.bmiHeader.biSizeImage = uSize;

	WRGBQUAD * pv = NULL;

	lv->hBitmap = CreateDIBSection( lv->hDC, &bmi, DIB_RGB_COLORS, (PVOID*) &lv->pvBits, NULL, 0 );
	//	CreateCompatibleBitmap(lv->hDesktopDC, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));

	lv->hOldBmp = HBITMAP(SelectObject(lv->hDC, lv->hBitmap));

	SetWindowLongPtr(hwnd, 16, LPARAM(lv));
	return lv;
}
Example #5
0
//透明绘画
bool CSkinImage::AlphaDrawImageEx(CDC * pDestDC, int xDest, int yDest, int cxDest, int cyDest, int xSrc, int ySrc, COLORREF crTrans)
{
	//效验状态
	if (IsNull()) return false;

	//建立 DC
	CDC DCImage;
	DCImage.CreateCompatibleDC(pDestDC);
	DCImage.SelectObject(HBITMAP(*this));
	DCImage.SetBkColor(crTrans);
	DCImage.SetBkMode(TRANSPARENT);

	//建立掩码图
	CDC DCMask;
	CBitmap BMPMask;
	BMPMask.CreateBitmap(cxDest,cyDest,1,1,NULL);
	DCMask.CreateCompatibleDC(pDestDC);
	DCMask.SelectObject(&BMPMask);
	DCMask.BitBlt(0,0,cxDest,cyDest,&DCImage,xSrc,ySrc,SRCCOPY);

	//绘画目标图
	pDestDC->BitBlt(xDest,yDest,cxDest,cyDest,pDestDC,xDest,yDest,SRCCOPY);
	pDestDC->BitBlt(xDest,yDest,cxDest,cyDest,&DCImage,xSrc,ySrc,SRCINVERT);
	pDestDC->BitBlt(xDest,yDest,cxDest,cyDest,&DCMask,0,0,SRCAND);
	pDestDC->BitBlt(xDest,yDest,cxDest,cyDest,&DCImage,xSrc,ySrc,SRCINVERT);

	//清理资源
	DCMask.DeleteDC();
	DCImage.DeleteDC();
	BMPMask.DeleteObject();
	
	return true;
}
Example #6
0
//--------------------------------------------------
//-- ON_WM_MOUSEMOVE
// Change the bitmap to "selected" state
//---------------------------------------------------
void CBmpButton::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	SetBitmap(HBITMAP(m_bmpUp));

	CStatic::OnMouseMove(nFlags, point);
}
Example #7
0
File: Dib.cpp Project: F5000/spree
BOOL CDIB::DrawText(CDC *pDC, LPCTSTR szString, COLORREF fontcolor )
{
	CFont		pfont;	
	LOGFONT		lf;
	
	lf.lfHeight=16;
	lf.lfWidth=0;
	lf.lfEscapement=0;
	lf.lfOrientation=0;
	lf.lfWeight=FW_NORMAL;
	lf.lfItalic=0;
	lf.lfUnderline=0;
	lf.lfStrikeOut=0;
	lf.lfCharSet=DEFAULT_CHARSET; //ANSI_CHARSET;
	lf.lfOutPrecision=OUT_DEFAULT_PRECIS;
	lf.lfClipPrecision=CLIP_DEFAULT_PRECIS;
	lf.lfQuality=PROOF_QUALITY;
	lf.lfPitchAndFamily=VARIABLE_PITCH | FF_ROMAN;
	wcscpy(lf.lfFaceName, _T("MS Sans Serif") );
	
	pfont.CreateFontIndirect( &lf );		
	
	CDC BufferDC;
	CBitmap BufferBitmap, *OldBitmap;
	
	BufferDC.CreateCompatibleDC ( pDC );
	CFont *pOldFont = BufferDC.SelectObject(&pfont);
	
	SIZE  size;
	GetTextExtentPoint32( BufferDC.GetSafeHdc(), szString, wcslen(szString), &size );
	
	size.cx += 16;
	
	BufferBitmap.CreateCompatibleBitmap ( pDC, size.cx, size.cy );
	OldBitmap=BufferDC.SelectObject ( &BufferBitmap );
	
	BufferDC.FillSolidRect ( 0, 0, size.cx, size.cy, 0 );		
	
	RECT rect;
	rect.left = 2;
	rect.top  = 0;
	rect.right = size.cx-1;
	rect.bottom = size.cy-1;
	
	BufferDC.SetTextColor(fontcolor);	
	BufferDC.DrawText(szString,&rect,DT_LEFT|DT_VCENTER|DT_SINGLELINE);
	
	BufferDC.SelectObject ( OldBitmap );
	
	CDIB tempDIB;
	tempDIB.Create ( size.cx, size.cy );
	GetDIBits ( pDC->m_hDC, HBITMAP(BufferBitmap), 0, size.cy, tempDIB.m_Bits, &(tempDIB.m_Info), DIB_RGB_COLORS ); 	
	BufferDC.SelectObject(pOldFont);
	pfont.DeleteObject();

	BlendRect( &tempDIB, 0, 0 );
	
	return TRUE;
}
void CUIBitmapButton::OnMouseMove(UINT nFlags, CPoint point)
{
	//if(nIDMouseOn !=0){
		this->SetBitmap(HBITMAP(m_bmpMouseOn));
	//}

	CBitmapButton::OnMouseMove(nFlags, point);
}
void CUIBitmapButton::OnMouseLeave()
{
	//if(nIDNormal != 0){
		this->SetBitmap(HBITMAP(m_bmpNormal));
	//}

	CBitmapButton::OnMouseLeave();
}
void CUIBitmapButton::OnLButtonDown(UINT nFlags, CPoint point)
{
	//if(nIDMouseDown !=0){
		this->SetBitmap(HBITMAP(m_bmpMouseDown));
	//}

	CBitmapButton::OnLButtonDown(nFlags, point);
}
Example #11
0
void CSkinBtn::SetScrollDraw(int bDraw ,int nNum)
{
	HBITMAP szhBitmapNormal;
	szhBitmapNormal=HBITMAP(::LoadImage(AfxGetInstanceHandle(),_T("Image\\FolderScrollbar.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE));
	m_imgScroll.Attach(szhBitmapNormal);
	m_bDrawScroll = bDraw;
	m_BtnNum = nNum;
}
Example #12
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;
}
Example #13
0
BOOL CFirstTimeDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
    // Load the Get Abode bitmap
	m_Bitmap.LoadBitmap(MAKEINTRESOURCE(IDB_GETADOBE));
	GetDlgItem(IDC_GETADOBE)->SendMessage(BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)HBITMAP(m_Bitmap));

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Example #14
0
void CluckappDlg::genRandomResult()
{
	CImage *img=new CImage;
	CBitmap* bm;
	img->Load(_T("res/pic/photo.jpg"));

	HBITMAP hbmp =(HBITMAP)img->operator HBITMAP();
	for(int i=0; i<9; i++)
	{
		resultBmp[i].DeleteObject();
		resultBmp[i].Attach(hbmp);
	}

};
Example #15
0
File: Dib.cpp Project: F5000/spree
void CDIB::GetFromDC ( CDC *pDC, int x, int y, int w, int h )
{
    // If DibSize Wrong Re-Create Dib
    if ( (m_Size.cx!=w) || (m_Size.cy!=h) )
        Create ( w, h );
    
    CDC BufferDC;
    CBitmap BufferBitmap, *OldBitmap;

    BufferDC.CreateCompatibleDC ( pDC );
    BufferBitmap.CreateCompatibleBitmap ( pDC, w, h );
    OldBitmap=BufferDC.SelectObject ( &BufferBitmap );
    BufferDC.FillSolidRect ( 0, 0, w, h, 0 );
    BufferDC.BitBlt ( 0, 0, w, h, pDC, x, y, SRCCOPY );
    BufferDC.SelectObject ( OldBitmap );
    GetDIBits ( pDC->m_hDC, HBITMAP(BufferBitmap), 0, h, m_Bits, &(m_Info), DIB_RGB_COLORS ); 
}
Example #16
0
void CLightDlg::ColorButtons() {
	CRect r;

	CClientDC dc(this);
	
	CButton *pBtn = (CButton *)GetDlgItem(IDC_BTN_COLOR);
	pBtn->GetClientRect(&r);
	colorBitmap.DeleteObject();
	colorBitmap.CreateCompatibleBitmap(&dc, r.Width(), r.Height());
	CDC MemDC;
	MemDC.CreateCompatibleDC(&dc);
	CBitmap *pOldBmp = MemDC.SelectObject(&colorBitmap);
	{
		CBrush br(RGB(color[0], color[1], color[2])); 
		MemDC.FillRect(r,&br);
	}
	dc.SelectObject(pOldBmp);
	pBtn->SetBitmap(HBITMAP(colorBitmap)); 
}
Example #17
0
LRESULT CMenuDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	if (NULL == m_imgNoBtnSel)
		m_imgNoBtnSel.LoadFromFile(_T("NoSel.png"), true);

	HBITMAP hBitmap = m_imgNoBtnSel.operator HBITMAP();
	if (hBitmap)
	{
		// 根据位图创建客户区域,屏蔽掉红色
		HRGN hRgn = CreateRegionFromBitmap(hBitmap, 0xff0000, NULL);
		int nVal = ::SetWindowRgn(this->m_hWnd, hRgn, true);
	}

	long   lExStyle   =   ::GetWindowLong(m_hWnd,   GWL_EXSTYLE); 
	lExStyle   &=   ~WS_EX_APPWINDOW;
	lExStyle   |=   WS_EX_TOOLWINDOW;
	::SetWindowLong(m_hWnd,   GWL_EXSTYLE,   lExStyle);

	return TRUE;
}
Example #18
0
File: Dib.cpp Project: F5000/spree
BOOL CDIB::Create (CDC *pDC, UINT uBitmapID)
{   
	Destroy ();
	// Creates from a bitmap
    CDC BufferDC;
    CBitmap BufferBitmap, *OldBitmap;

    if (!BufferBitmap.LoadBitmap (uBitmapID))
        return FALSE;   // Can't load resource bitmap
    BITMAP bmpData;
    if (!BufferBitmap.GetBitmap (&bmpData))
        return FALSE;   // Can't get bitmap info
    if (!Create (bmpData.bmWidth, bmpData.bmHeight))
        return FALSE;   // Can't create DIB buffer

    BufferDC.CreateCompatibleDC (pDC);
    OldBitmap=BufferDC.SelectObject (&BufferBitmap);
    GetDIBits (BufferDC.m_hDC, HBITMAP(BufferBitmap), 0, m_Size.cy, m_Bits, &(m_Info), DIB_RGB_COLORS); 
    BufferDC.SelectObject (OldBitmap);
    BufferBitmap.DeleteObject();
    return TRUE;
}
Example #19
0
//--------------------------------------------------
//-- ResetButton
// Use this function to set the button default state
//---------------------------------------------------
void CBmpButton::ResetButton()
{
	SetBitmap(HBITMAP(m_bmpDefault));
}
Example #20
0
void CHTMLViewCapView::SaveImages(CList<CHTMLViewCapUrl> &lstUrl)
{
	// 
	POSITION pos = NULL;

	// 浏览器和图片的宽度和高度
	DWORD nWidth  = 1024;
	DWORD nHeight = 2048;

	IDispatch *pDoc = NULL;
	IViewObject *pViewObject = NULL;
	VARIANT vUrl;
	VARIANT vUrlName;

	//
	CTime t;
	CString csTime, csDate, csMark1;
	CString csPath;
	CString csFileName;
	HRESULT hr;

	//
	CBitmap *pBM;
	Bitmap *gdiBMP;
	// 用于生成图片的序数
	static DWORD nNum = 0;

	/*
			创建字体
	*/
	HFONT hfont;
	LOGFONT lf;
	ZeroMemory(&lf, sizeof(lf));
	lf.lfHeight   =   0;
	lf.lfWidth    =   0;
	lf.lfEscapement   =   0;
	lf.lfOrientation   =   0;
	lf.lfStrikeOut   =   FALSE;
	lf.lfCharSet   =   DEFAULT_CHARSET;
	lf.lfOutPrecision   =   OUT_DEFAULT_PRECIS;  
	lf.lfClipPrecision   =   CLIP_DEFAULT_PRECIS;  
	lf.lfQuality   =   ANTIALIASED_QUALITY;
	lf.lfPitchAndFamily =   VARIABLE_PITCH;
	lstrcpy(lf.lfFaceName,   _T("微软雅黑"));
	hfont   =   CreateFontIndirect(&lf);

	// 循环遍历所有URL
	for (pos = lstUrl.GetHeadPosition();
		   pos != NULL;
		   lstUrl.GetNext(pos))
	{
		// 获取图片和浏览器分辨率
		nWidth  = lstUrl.GetAt(pos).m_nWidth;
		nHeight = lstUrl.GetAt(pos).m_nHeight;
		CString &csUrl = lstUrl.GetAt(pos).m_csUrl;
		CBitmapDC destDC(nWidth, nHeight);

		// 创建 媒体名称目录
		csPath = ::theApp.m_csImageDir;
		csPath.Append(_T("\\"));
		if (lstUrl.GetAt(pos).m_bHasMediaName) {
			csPath.Append(lstUrl.GetAt(pos).m_csMediaName);
		}  else {
			csPath.Append(lstUrl.GetAt(pos).getMediaNameInUrl());
		}

		::CreateDirectory(csPath, NULL);

		// 创建输出文件路径
		t = CTime::GetCurrentTime();
		csTime = t.Format("\\%H时%M分%S秒-");
		csMark1 = t.Format("%H:%M");
		csDate    = t.Format(" %Y/%m/%d");
		csPath.Append(csTime);

		vUrl.vt = ::VT_BSTR;
		vUrl.bstrVal = (BSTR)csUrl.GetString();  

		m_pBrowserApp->put_Width(nWidth);
		m_pBrowserApp->put_Height(nHeight);

		if (m_pBrowserApp->Navigate2(&vUrl, NULL, NULL, NULL, NULL) == S_OK)
		{
			m_tBeforeEnterLoop = CTime::GetCurrentTime();
			RunModalLoop();
		} else {
			TRACE(_T("%d Document Navigate Failed!\n"), vUrl);
			MessageBox(_T("Navi Error"), _T("Error"), MB_OK);
			return ;
		}
		TRACE("Begin Cap!\n");
		// wait for document to load
		m_pBrowserApp->Refresh();

		// render to enhanced metafile HDC.
		hr = m_pBrowserApp->get_Document(&pDoc);

		if (hr != S_OK) {
			TRACE(_T("%s get_Document failed!\n"), vUrl.bstrVal);
			return ;
		}

		pDoc->QueryInterface(IID_IViewObject, (void**)&pViewObject); // result is first div of document

		if (pDoc == NULL) {
			TRACE(_T("%d query IID_IViewObject failed!\n"), vUrl.bstrVal);
			return ;
		}

		hr = OleDraw(pViewObject, DVASPECT_CONTENT, destDC, NULL);
		if (hr != S_OK) {
			TRACE(_T("%s OleDraw failed!\n"), vUrl.bstrVal);
			return ;
		} 

		/*
				使用字体
		*/
		destDC.SelectObject(hfont);
		destDC.SetTextColor(RGB(0, 0, 0));
		destDC.SetBkColor(RGB(235, 231, 228));
		//destDC.SetBkMode(TRANSPARENT);

        // 输出水印
		TextOut(destDC, nWidth - 70, nHeight - 100, (LPCTSTR)csMark1, csMark1.GetLength()); 
		TextOut(destDC, nWidth - 100, nHeight - 70, (LPCTSTR)csDate, csDate.GetLength()); 
		pBM = destDC.Close();
		gdiBMP = Bitmap::FromHBITMAP(HBITMAP(pBM->GetSafeHandle()), NULL);

		csFileName.Format(_T("%u.jpg"), nNum++);
		csPath.Append(csFileName);
		
		// 保存图片
		gdiBMP->Save(csPath.GetString(), &m_jpegClsid, NULL);
	
		// 清理资源
		delete gdiBMP;
		pBM->DeleteObject();
		pViewObject->Release();
		pDoc->Release();
	}
}
BOOL CScanFashionDlg::control_change()
{
	int i, j, k;

	// Step1: ReCompute the row and column numbers	
    // Step2: Generate views' topology in the scan area
	// Step3: Compute total scan area
	if ( !generate_area_topology() )
	{
		return FALSE;
	}

	// Step4: Set scan sequence
	set_scan_sequence();

	// Step5: Display scan area
	// Step5.1: read the slide bitmap
	m_slidebmp.DeleteObject();
	if( ! m_slidebmp.LoadBitmapW(IDB_SLIDE) )
	{
		AfxMessageBox(_T("不能加载位图资源"));
		return FALSE;
	}
	std::auto_ptr<BYTE> pSlideBmpData(new BYTE[m_slidebmp_byteCount]);	
	LPCOLORREF pBmpData = NULL;
	pBmpData = (LPCOLORREF) pSlideBmpData.get();
	if (pBmpData)
	{
		m_slidebmp.GetBitmapBits(m_slidebmp_byteCount, (LPVOID)pBmpData );
	}
	else
	{
		AfxMessageBox(_T("内存不足,不能加载位图资源"));
		return FALSE;
	}
	
	// Step5.2: add the views in the slide bitmap
	CPoint view_position_in_SlideBmp;
	for ( k=0; k<m_view_total_num; k++ )
	{
		view_position_in_SlideBmp.x = LONG(m_area_topology[k].x/m_scan_fashion_display_ratio);
		view_position_in_SlideBmp.y = LONG(m_area_topology[k].y/m_scan_fashion_display_ratio);
		view_position_in_SlideBmp = m_slidebmp_origin - view_position_in_SlideBmp;

		if ( (view_position_in_SlideBmp.x < 0) || (view_position_in_SlideBmp.x > m_slidebmp_width-10 ) 
				|| (view_position_in_SlideBmp.y < 0 ) || (view_position_in_SlideBmp.y>m_slidebmp_height-10) )
		{
			AfxMessageBox(_T("扫描范围溢出显示示意图"));
			return FALSE;
		}

		// set black color as the representation of the views' position in the bitmap 
		for ( i=0; i<3; i++ )
		{
			for ( j=0; j<2; j++ )
			{
				pBmpData[(view_position_in_SlideBmp.y+j) * m_slidebmp_width + view_position_in_SlideBmp.x + i] = RGB(0,0,0);
			}
		}
	}

	// Step5.3: set red color as the start view in the bitmap
	MATRIXINDEX firstFOVIndex = m_area_scan_sequence[0];
	cv::Point2f firstFOVPosition = m_area_topology[firstFOVIndex.row * m_view_column_num + firstFOVIndex.col ];
	view_position_in_SlideBmp.x = LONG(firstFOVPosition.x/m_scan_fashion_display_ratio);
	view_position_in_SlideBmp.y = LONG(firstFOVPosition.y/m_scan_fashion_display_ratio);
	view_position_in_SlideBmp = m_slidebmp_origin - view_position_in_SlideBmp;
	for ( i = 0; i<5; i++ )
	{
		for ( j=0; j<5; j++ )
		{
			pBmpData[(view_position_in_SlideBmp.y+j) * m_slidebmp_width + view_position_in_SlideBmp.x + i ] = RGB(255,0,0);
		}
	}
	// Step5: Display scan area
	m_slidebmp.SetBitmapBits(m_slidebmp_byteCount, (const void*)pBmpData );
	pBmpData = NULL;
	m_hSlidBitmap = HBITMAP(m_slidebmp);

	return TRUE;
}
Example #22
0
CMenu* CCementBD::SetModulesExtern()
{
	if(gListModuleExternal.GetCount() == 0) return 0;
    //---------------------------------------------------
    //Формируем меню внешних модулей
    CCementDoc* pDoc = (CCementDoc*)GetDocument();
	HINSTANCE hInst = AfxGetResourceHandle();
    pDoc->m_DefaultMenu = 
        ::LoadMenu(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_KRSCEMENTTYPE));
    if (pDoc->m_DefaultMenu == NULL)
        return 0;

    CMenu* menu = CMenu::FromHandle(pDoc->GetDefaultMenu());
    if(menu)
    {
        int iPos;
        CMenu* pPopup = NULL;
        for(iPos = 0; iPos < (int)menu->GetMenuItemCount(); iPos++)
        {
            if(menu->GetSubMenu(iPos)->GetMenuItemID(0) == ID_NASTROIKA_MODULES) 
            {
                pPopup = menu->GetSubMenu(iPos);
 		int ii = (int)pPopup->GetMenuItemCount();
               break;
            }
        }
        if(pPopup == NULL) return 0;


		CMenu *submenu = menu->GetSubMenu(iPos);
		if(submenu == NULL) return 0;
		int ii = (int)submenu->GetMenuItemCount();


        int cx = ::GetSystemMetrics(SM_CXMENUCHECK);
        int cy = ::GetSystemMetrics(SM_CYMENUCHECK);
        if(pPopup != NULL && gListModuleExternal.GetCount() > 0) 
        {
            pPopup->AppendMenu(MF_SEPARATOR, 0, LPCTSTR(0));

            for(int i = 0; i < gListModuleExternal.GetCount(); i++)
            {
                HICON hIconLarge, hIcon;
//                ExtractIconEx(gListModuleExternal.GetName2(i), 0, &hIconLarge, &hIcon, 1);
				CString Name2 = gListModuleExternal.GetName2txe(i);
				if(Name2.GetLength() == 0) continue;
				ExtractIconEx(Name2, 0, &hIconLarge, &hIcon, 1);
                //HICON hIcon = ExtractIcon(pApp->m_hInstance, gListModuleExternal.GetName2(i), 0);
                if(hIcon != NULL)
                {
                    ICONINFO iconinfo;
                    GetIconInfo(hIcon, &iconinfo);
                    HANDLE hLoad = CopyImage(HANDLE(iconinfo.hbmColor), IMAGE_BITMAP, cx+1, cy+1, LR_COPYFROMRESOURCE);
                    CBitmap *pBmp = CBitmap::FromHandle(HBITMAP(hLoad));
                    CString str;
                    str.Format(" %d", i);
                    str += ".  " + gListModuleExternal.GetName(i);
                    BOOL flg = pPopup->AppendMenu(MF_STRING | MF_ENABLED, ID_MENU_MODULE_EXTERNAL + i, str);
                    pPopup->SetMenuItemBitmaps(i+2, MF_BYPOSITION, pBmp, pBmp);
                    //BOOL res = menu->SetMenuItemBitmaps(2, MF_BYPOSITION, pBmp, pBmp);
                    //int zzz = 0;
                }
            }
        }
        CMDIFrameWnd* frame = ((CMDIChildWnd *) GetParent())->GetMDIFrame();
        frame->MDISetMenu(menu, NULL);
        frame->DrawMenuBar();
    }
    //-------------------------------------------------------------------------
	return menu;
}
void CUIBitmapButton::SetNormalBmp()
{
	//if(nIDNormal !=0){
		this->SetBitmap(HBITMAP(m_bmpNormal));
	//}
}
void SaveImage(HDC hDC, HBITMAP bitmap, LPCTSTR lpszSavepath)
{
	BITMAP bmp;
	PBITMAPINFO pbmi;
	WORD cClrBits;
	HANDLE hf; // file handle
	BITMAPFILEHEADER hdr; // bitmap file-header
	PBITMAPINFOHEADER pbih; // bitmap info-header
	LPBYTE lpBits; // memory pointer
	DWORD dwTotal; // total count of bytes
	DWORD cb; // incremental count of bytes
	BYTE *hp; // byte pointer
	DWORD dwTmp;

	// create the bitmapinfo header information
	if (!GetObject(bitmap, sizeof(BITMAP), (LPSTR)&bmp))
		return;

	// Convert the color format to a count of bits.
	cClrBits = (WORD)(bmp.bmPlanes * bmp.bmBitsPixel);
	if (cClrBits == 1)
	cClrBits = 1;
	else if (cClrBits <= 4)
	cClrBits = 4;
	else if (cClrBits <= 8)
	cClrBits = 8;
	else if (cClrBits <= 16)
	cClrBits = 16;
	else if (cClrBits <= 24)
	cClrBits = 24;
	else cClrBits = 32;
 
	// Allocate memory for the BITMAPINFO structure.
	if (cClrBits != 24)
	pbmi = (PBITMAPINFO) LocalAlloc(LPTR,
	sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * (1<< cClrBits));
	else
	pbmi = (PBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER));

	// Initialize the fields in the BITMAPINFO structure.
	pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	pbmi->bmiHeader.biWidth = bmp.bmWidth;
	pbmi->bmiHeader.biHeight = bmp.bmHeight;
	pbmi->bmiHeader.biPlanes = bmp.bmPlanes;
	pbmi->bmiHeader.biBitCount = bmp.bmBitsPixel;

	if (cClrBits < 24)
		pbmi->bmiHeader.biClrUsed = (1<<cClrBits);

	// If the bitmap is not compressed, set the BI_RGB flag.
	pbmi->bmiHeader.biCompression = BI_RGB;

	// Compute the number of bytes in the array of color
	// indices and store the result in biSizeImage.
	pbmi->bmiHeader.biSizeImage = (pbmi->bmiHeader.biWidth + 7) /8 * pbmi->bmiHeader.biHeight * cClrBits;
	// Set biClrImportant to 0, indicating that all of the
	// device colors are important.
	pbmi->bmiHeader.biClrImportant = 0;

	// now open file and save the data
	pbih = (PBITMAPINFOHEADER) pbmi;
	lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage);

	if (!lpBits)
		return;

	// Retrieve the color table (RGBQUAD array) and the bits
	if (!GetDIBits(hDC, HBITMAP(bitmap), 0, (WORD) pbih->biHeight, lpBits, pbmi, DIB_RGB_COLORS)) 
		return;

	// Create the .BMP file.
	hf = CreateFile(lpszSavepath, GENERIC_READ | GENERIC_WRITE, (DWORD) 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 	(HANDLE) NULL);

	if (hf == INVALID_HANDLE_VALUE)
		return;

	hdr.bfType = 0x4d42; // 0x42 = "B" 0x4d = "M"
	// Compute the size of the entire file.
	hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) + pbih->biSize + pbih->biClrUsed* sizeof(RGBQUAD) + pbih->biSizeImage);
	hdr.bfReserved1 = 0;
	hdr.bfReserved2 = 0;

	// Compute the offset to the array of color indices.
	hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) +pbih->biSize + pbih->biClrUsed* sizeof (RGBQUAD);

	// Copy the BITMAPFILEHEADER into the .BMP file.
	if (!WriteFile(hf, (LPVOID) &hdr, sizeof(BITMAPFILEHEADER),(LPDWORD) &dwTmp, NULL)) 
		return;

	// Copy the BITMAPINFOHEADER and RGBQUAD array into the file.
	if (!WriteFile(hf, (LPVOID) pbih, sizeof(BITMAPINFOHEADER)+ pbih->biClrUsed * sizeof (RGBQUAD),(LPDWORD) &dwTmp, ( NULL)))
		return;
	// Copy the array of color indices into the .BMP file.
	dwTotal = cb = pbih->biSizeImage;
	hp = lpBits;

	if (!WriteFile(hf, (LPSTR) hp, (int) cb, (LPDWORD) &dwTmp,NULL))
		return;

	CloseHandle(hf);
	// Free memory.
	GlobalFree((HGLOBAL)lpBits);
}
Example #25
0
LRESULT CMenuDlg::OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	CPaintDC dc(m_hWnd);
	int nBeginHight = 14;

	int nBtnHight = 25;

	// 如果选中的按钮没有发生改变,就没有必要进行重绘
	if (m_nBtnSelIndex == m_nBtnLastSel && m_nBtnSelIndex != -1)
		return 0;

	HBITMAP hBitmap = m_imgNoBtnSel.operator HBITMAP();

	BITMAP	bm;
	::GetObject(hBitmap, sizeof(BITMAP), &bm);
	int nWidth = bm.bmWidth;
	int nHeight = bm.bmHeight;

	HDC hhMemDC = ::CreateCompatibleDC(NULL);
	BITMAPINFOHEADER bmi = {sizeof(BITMAPINFOHEADER), nWidth, nHeight, 1, 32, BI_RGB, 0, 0, 0, 0, 0};
	void* pBits32 = NULL;

	// 创建位图部件(Section)(用来复制位图)
	HBITMAP hBmpSection = ::CreateDIBSection(hhMemDC, (BITMAPINFO*)&bmi, DIB_RGB_COLORS, &pBits32, NULL, 0);
	if (hBmpSection == NULL)
	{
		::DeleteDC(hhMemDC);
		return 0;
	}

	// 将位图选中到DC中
	HBITMAP hDefBmp = (HBITMAP)::SelectObject(hhMemDC, hBmpSection);

	HDC hTmpDC = ::CreateCompatibleDC(NULL);
	HBITMAP hTmpBmp = (HBITMAP)::SelectObject(hTmpDC, (HBITMAP)hBitmap);
	// 将原来的位图数据复制到新生成的位图中
	::BitBlt(hhMemDC, 0, 0, nWidth, nHeight, hTmpDC, 0, 0, SRCCOPY);

	BYTE* lpBits = NULL;

	if (m_nBtnSelIndex > 0 && m_nBtnSelIndex < 5)
	{
		// 因为GetDIBits 得到的图片是逆过来的
		DWORD dwLoopYB = bm.bmHeight - (nBeginHight + (m_nBtnSelIndex - 1) * (nBtnHight + 1));
		
		PBITMAPINFO bmpInf;  
		int nPaletteSize=0;   
		
		bmpInf = (PBITMAPINFO)LocalAlloc(LPTR,sizeof(BITMAPINFOHEADER) +(bm.bmWidth+7)/8*bm.bmHeight*bm.bmBitsPixel);
		BYTE* buf = ((BYTE*)bmpInf) + sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*nPaletteSize;  

		bmpInf->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);   
		bmpInf->bmiHeader.biWidth = bm.bmWidth;   
		bmpInf->bmiHeader.biHeight = bm.bmHeight;   
		bmpInf->bmiHeader.biPlanes = bm.bmPlanes;   
		bmpInf->bmiHeader.biBitCount = bm.bmBitsPixel;   
		bmpInf->bmiHeader.biCompression = BI_RGB;   
		bmpInf->bmiHeader.biSizeImage = 0;//(bm.bmWidth+7)/8*bm.bmHeight*bm.bmBitsPixel;

		// 得到位图的数据
		int nLine = GetDIBits(hhMemDC, hBmpSection, 0,(UINT)bm.bmHeight, buf, bmpInf, DIB_RGB_COLORS);

		int nOffset = 0;
		if(bmpInf->bmiHeader.biBitCount == 32)   
		{   
			// 根据用户鼠标的位置,对位图进行选中着色
			for(int i = dwLoopYB - nBtnHight; i < dwLoopYB; i++)   
			{   
				nOffset = i * nWidth * 4;   
				for(int j=0; j<bm.bmWidth; j++)   
				{   
					int b = buf[nOffset+j*4];   
					int g = buf[nOffset+j*4+1];   
					int r = buf[nOffset+j*4+2]; 

					buf[nOffset+j*4] = b * 0.875;
					buf[nOffset+j*4 + 1] = g * 0.885;
					buf[nOffset+j*4 + 2] = r * 0.895;

				}   
			}
		}

		// 将修改后的位图数据写入到位图中
		SetDIBits(hhMemDC, hBmpSection, 0,(UINT)bm.bmHeight, buf, bmpInf, DIB_RGB_COLORS);
		///////////////////////////////////////////////////////////22222222222222222
		/*switch(m_nBtnSelIndex)
		{
		case 1:
			if (NULL != m_imgSelBtn1)
				hBitmap = m_imgSelBtn1.operator HBITMAP();
			break;

		case 2:
			if (NULL != m_imgSelBtn1)
				hBitmap = m_imgSelBtn2.operator HBITMAP();
			break;

		case 3:
			if (NULL != m_imgSelBtn1)
				hBitmap = m_imgSelBtn3.operator HBITMAP();
			break;

		case 4:
			if (NULL != m_imgSelBtn1)
				hBitmap = m_imgSelBtn4.operator HBITMAP();
			break;

		default:
			break;
		}

		::GetObject(hBitmap, sizeof(BITMAP), &bm);
		nWidth = bm.bmWidth;
		nHeight = bm.bmHeight;

		::SelectObject(hTmpDC, (HBITMAP)hBitmap);*/

		//::BitBlt(dc, 0, dwLoopYB, nWidth, nHeight, hTmpDC, 0, 0, SRCCOPY);
		m_nBtnLastSel = m_nBtnSelIndex;
		LocalFree(bmpInf);

		//////////////////////////////////////////////////////11111111111
		//DWORD		dwLoopYB = 0, dwLoopYE = 0, dwLoopXB = 0, dwLoopXE = 0;
		//m_nBtnLastSel = m_nBtnSelIndex;
		//dwLoopYB = nBeginHight + (m_nBtnSelIndex - 1) * (nBtnHight + 1) + 1;
		//dwLoopYE = nBtnHight + dwLoopYB;
		//dwLoopXB = 1;

		//dwLoopXE = m_imgNoBtnSel.GetWidth() - 1;

		//DWORD		dwLoopY = 0, dwLoopX = 0;
		//COLORREF	crPixel = 0;
		//BYTE		byNewPixel = 0;

		//for (dwLoopY = dwLoopYB; dwLoopY < dwLoopYE; dwLoopY++)
		//{
		//	for (dwLoopX = dwLoopXB; dwLoopX < dwLoopXE; dwLoopX++)
		//	{
		//		crPixel = ::GetPixel(dc, dwLoopX, dwLoopY);
		//		//::SetPixel(dc, dwLoopX, dwLoopY, RGB(GetRValue(crPixel) * 0.895, GetGValue(crPixel) * 0.885, GetBValue(crPixel) * 0.875));

		//	} // for
		//} // for

	}
	else
	{
		m_nBtnLastSel = 0;
	}

	// 将位图的数据拷贝到客户DC中去
	::BitBlt(dc, 0, 0, nWidth, nHeight, hhMemDC, 0, 0, SRCCOPY);

	if (NULL !=  lpBits)
		delete []lpBits;

	::DeleteDC(hTmpDC);
	::DeleteDC(hhMemDC);
	::DeleteObject(hBmpSection);
	return 0;
}
Example #26
0
BOOL CTrayNotifyIcon::GetDynamicDCAndBitmap(CDC* pDC, CBitmap* pBitmap)
{
    //Validate our parameters
    ATLASSERT(pDC != NULL);
    ATLASSERT(pBitmap != NULL);

    //Get the HWND for the desktop
#ifdef _AFX
    CWnd* pWndScreen = CWnd::GetDesktopWindow();
    if (pWndScreen == NULL)
        return FALSE;
#else
    CWindow WndScreen(::GetDesktopWindow());
    if (!WndScreen.IsWindow())
        return FALSE;
#endif

    //Get the desktop HDC to create a compatible bitmap from
#ifdef _AFX
    CDC* pDCScreen = pWndScreen->GetDC();
    if (pDCScreen == NULL)
        return FALSE;
#else
    CDC DCScreen(WndScreen.GetDC());
    if (DCScreen.IsNull())
        return FALSE;
#endif

    //Get the width and height of a small icon
    int w = GetSystemMetrics(SM_CXSMICON);
    int h = GetSystemMetrics(SM_CYSMICON);

    //Create an off-screen bitmap that the dynamic tray icon
    //can be drawn into. (Compatible with the desktop DC).
#ifdef _AFX
    BOOL bSuccess = pBitmap->CreateCompatibleBitmap(pDCScreen, w, h);
#else
    BOOL bSuccess = (pBitmap->CreateCompatibleBitmap(DCScreen.operator HDC(), w, h) != NULL);
#endif
    if (!bSuccess)
    {
#ifdef _AFX
        pWndScreen->ReleaseDC(pDCScreen);
#else
        WndScreen.ReleaseDC(DCScreen);
#endif
        return FALSE;
    }

    //Get a HDC to the newly created off-screen bitmap
#ifdef _AFX
    bSuccess = pDC->CreateCompatibleDC(pDCScreen);
#else
    bSuccess = (pDC->CreateCompatibleDC(DCScreen.operator HDC()) != NULL);
#endif
    if (!bSuccess)
    {
        //Release the Screen DC now that we are finished with it
#ifdef _AFX
        pWndScreen->ReleaseDC(pDCScreen);
#else
        WndScreen.ReleaseDC(DCScreen);
#endif

        //Free up the bitmap now that we are finished with it
        pBitmap->DeleteObject();

        return FALSE;
    }

    //Select the bitmap into the offscreen DC
#ifdef _AFX
    pDC->SelectObject(pBitmap);
#else
    pDC->SelectBitmap(pBitmap->operator HBITMAP());
#endif

    //Release the Screen DC now that we are finished with it
#ifdef _AFX
    pWndScreen->ReleaseDC(pDCScreen);
#else
    WndScreen.ReleaseDC(DCScreen);
#endif

    return TRUE;
}
BOOL COXScreenGrabber::GrabRectangle(CRect SrcRect)
{
	CDC SrcDC, MemDC;

	// Check For an empty rectangle
	if(SrcRect.IsRectEmpty())
		return FALSE;

	MSG msg;
	while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != 0)
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	// create a DC for the screen and create
	// a memory DC compatible to screen DC
	if (!SrcDC.CreateDC(_T("DISPLAY"), NULL, NULL, NULL))
		return FALSE;
	if (!MemDC.CreateCompatibleDC(&SrcDC))
	{
		SrcDC.DeleteDC();
		return FALSE;
	}

	// get screen resolution
	int nXScrn = SrcDC.GetDeviceCaps(HORZRES);
	int nYScrn = SrcDC.GetDeviceCaps(VERTRES);

#if(WINVER >= 0x0500)

	DISPLAY_DEVICE display;
	display.cb = sizeof(DISPLAY_DEVICE);
	if (EnumDisplayDevices(NULL, 1, &display, 0))
	{
		DEVMODE devMode;
		devMode.dmSize = sizeof(DEVMODE);
		if (EnumDisplaySettings((LPCTSTR)&display.DeviceName[0], ENUM_CURRENT_SETTINGS, &devMode))
		{
			// This assumes that the second monitor is set to draw to the 'right' of the first one.
			nXScrn += devMode.dmPelsWidth;
		}
	}

#endif

	// make sure window rectangle is visible
	if (SrcRect.left < 0)
		SrcRect.left = 0;
	if (SrcRect.top < 0)
		SrcRect.top = 0;
	if (SrcRect.right > nXScrn)
		SrcRect.right = nXScrn;
	if (SrcRect.bottom > nYScrn)
		SrcRect.bottom = nYScrn;

	// create a bitmap compatible with the screen DC
	CBitmap ScreenBMP;
	if(!ScreenBMP.CreateCompatibleBitmap(&SrcDC, SrcRect.Width(), SrcRect.Height()))
	{
		SrcDC.DeleteDC();
		MemDC.DeleteDC();

		return FALSE;
	}

	// select new bitmap into memory DC
	CBitmap* pOldBitmap = MemDC.SelectObject(&ScreenBMP);

	// bitblt screen DC to memory DC
	MemDC.BitBlt(0, 0, SrcRect.Width(), SrcRect.Height(), &SrcDC, SrcRect.left, SrcRect.top, SRCCOPY);

	// select old bitmap back into memory DC 
	MemDC.SelectObject(pOldBitmap);

	// Clear previous contents of DIB 
	GrabDIB.Empty();

	CPalette SysPalette;
	COXDIB::GetSystemPalette(&SysPalette);
	GrabDIB.BitmapToDIB(HBITMAP(ScreenBMP), &SysPalette);

	// clean up
	SrcDC.DeleteDC();
	MemDC.DeleteDC();

	return TRUE;
}
Example #28
0
//----------------------------------------------------------------------------------------------------------
// This function draws Themes Tab control parts: a) Tab-Body and b) Tab-tabs
void CXPTabCtrl::DrawThemesXpTabItem(CDC* pDC, int ixItem, const CRect& rcItem, UINT uiFlag) 
{            // uiFlag(1/0):1=Type(body/tab);2=Sel(y/n);4=Hot(y/n);8=bBottom(y/n);16=rotate(y/n)
    BOOL bBody  =(uiFlag& 1)?TRUE:FALSE;
    BOOL bSel   =(uiFlag& 2)?TRUE:FALSE;
    BOOL bHot   =(uiFlag& 4)?TRUE:FALSE;
    BOOL bBottom=(uiFlag& 8)?TRUE:FALSE;    // mirror
    BOOL bVertic=(uiFlag&16)?TRUE:FALSE;    // rotate
    BOOL bLeftTab=!bBottom && bVertic && !bBody;

    CSize szBmp=rcItem.Size();
    if(bVertic) SwapVars(szBmp.cx,szBmp.cy);
    // 1st draw background
    CDC     dcMem;    dcMem .CreateCompatibleDC(pDC);
    CBitmap bmpMem; bmpMem.CreateCompatibleBitmap(pDC,szBmp.cx,szBmp.cy);
    CBitmap* pBmpOld=dcMem.SelectObject(&bmpMem);
    CRect rcMem(CPoint(0,0),szBmp); if(bSel) rcMem.bottom++;
    if(bBody)
        DrawThemesPart(dcMem.GetSafeHdc(), 9, 0, (LPCSTR)IDS_UTIL_TAB, &rcMem);    // TABP_PANE=9,  0, 'TAB'
    else DrawThemesPart(dcMem.GetSafeHdc(), 1, bSel?3:(bHot?2:1), (LPCSTR)IDS_UTIL_TAB, &rcMem);
    // TABP_TABITEM=1, TIS_SELECTED=3:TIS_HOT=2:TIS_NORMAL=1, 'TAB'
    // 2nd init some extra parameters
    BITMAPINFO biOut; ZeroMemory(&biOut,sizeof(BITMAPINFO));    // Fill local pixel arrays
    BITMAPINFOHEADER& bihOut=biOut.bmiHeader;
    bihOut.biSize  =sizeof (BITMAPINFOHEADER);
    bihOut.biCompression=BI_RGB;
    bihOut.biPlanes=1;          bihOut.biBitCount=24;    // force as RGB: 3 bytes,24 bits -> good for rotating bitmap in any resolution
    bihOut.biWidth =szBmp.cx; bihOut.biHeight=szBmp.cy;

    int nBmpWdtPS=DWordAlign(szBmp.cx*3);
    int nSzBuffPS=((nBmpWdtPS*szBmp.cy)/8+2)*8;
    LPBYTE pcImg=NULL;
    if(bBottom || bVertic) { pcImg=new BYTE[nSzBuffPS]; ASSERT(pcImg); }
    int nStart=0,nLenSub=0;
    if(bBody && bBottom && !bVertic) nStart=3,nLenSub=4;    // if bottom oriented flip the body contest only (no shadows were flipped)
    // 3rd if it is left oriented tab, draw tab context before mirroring or rotating (before GetDIBits)
    if(bVertic)
    {    if(bBody || !bBottom) bihOut.biHeight=-szBmp.cy;
    if(!bBottom && !bBody && ixItem>=0)                    // 
    {    if(bSel) rcMem.bottom--;
    DrawTabItem(&dcMem, ixItem, rcMem, uiFlag); ixItem=-1;
    }    }                                                        // rotate or mirror
    // 4th get bits (for rotate) and mirror: body=(all except top) tab=(all except top)
    if(bVertic || bBottom)                                        // get bits: 
    {    GetDIBits(*pDC, bmpMem.operator HBITMAP(),nStart,szBmp.cy-nLenSub,pcImg,&biOut,DIB_RGB_COLORS);
    if(bBottom)                                    // mirror: body=(bottom and right) tab=(bottom and right)
    {    bihOut.biHeight=-szBmp.cy;                 // to mirror bitmap is eough to use negative height between Get/SetDIBits
    SetDIBits(*pDC, bmpMem.operator HBITMAP(),nStart,szBmp.cy-nLenSub,pcImg,&biOut,DIB_RGB_COLORS);
    if(bBody && bVertic)                    // when it is right oriented body -> flip twice, first flip border shadows, than flip shaded inside body again
    {    nStart=2; nLenSub=4; bihOut.biHeight=szBmp.cy;
    GetDIBits(*pDC, bmpMem.operator HBITMAP(),nStart,szBmp.cy-nLenSub,pcImg,&biOut,DIB_RGB_COLORS);
    bihOut.biHeight=-szBmp.cy;            // to mirror bitmap is eough to use negative height between Get/SetDIBits
    SetDIBits(*pDC, bmpMem.operator HBITMAP(),nStart,szBmp.cy-nLenSub,pcImg,&biOut,DIB_RGB_COLORS);
    }    }    }
    // 5th if it is bottom or right oriented tab, draw after mirroring background (do GetDIBits again)
    if(!bBody && ixItem>=0)                            // 
    {    if(bSel) rcMem.bottom--;
    DrawTabItem(&dcMem, ixItem, rcMem, uiFlag);
    if(bVertic)                                            // if it is right tab, do GetDIBits again
    {    bihOut.biHeight=-szBmp.cy;
    GetDIBits(*pDC, bmpMem.operator HBITMAP(),nStart,szBmp.cy-nLenSub,pcImg,&biOut,DIB_RGB_COLORS);
    }    }
    // 6th: do rotate now, finaly
    if(bVertic)                            // force rotating bitmap as RGB -> good for any resolution
    {    SwapVars(szBmp.cx,szBmp.cy);

    int nBmpWdtPD=DWordAlign(szBmp.cx*3);
    int nPadD=nBmpWdtPD-szBmp.cx*3;
    int nSzBuffPD=((nBmpWdtPD*szBmp.cy)/8+2)*8;
    LPBYTE pcImgRotate=new BYTE[nSzBuffPD]; ASSERT(pcImgRotate);
    int nWidth,nHeight=szBmp.cy,nHeight1=nHeight-1;
    //====================================
    //------------------------------------
    // here is the example how to speed up lengthy repeatetive processing by using inline assembler
#if !defined(_AMD64_)
#define __USE_MASM__        // the same processing is in C and in asm. To use C -> comment the beginning of this line
#endif
    // Do the actual whole RGB bitmap rotating in C or assembler
#ifndef __USE_MASM__
    LPBYTE pcImgS=pcImg;
    LPBYTE pcImgD=pcImgRotate;
    int ixHeight=0;
    BOOL bLast=FALSE;
    while(ixHeight<nHeight)                    // for all destination height lines
    {    
        nWidth=szBmp.cx;
        if(ixHeight==nHeight1) { bLast=TRUE; nWidth--; }

        while(nWidth--)
        {    
            *(PDWORD)pcImgD=*(PDWORD)pcImgS; // do all Rgb triplets read/write qicker as DWORD
            pcImgS+=nBmpWdtPS;    // increment source in padded source lines
            pcImgD+=3;            // increment destination in rgb triplets
        }

        if(bLast)                // when the last line, the last pixel - colud be a problem if bitmap DWORD alligned 
            for(int c=3;c;c--) 
                *pcImgD++=*pcImgS++;        // (only last three bytes available->could not read/write DWORD)!!
        else
        {    
            ixHeight++;
            pcImgD+=nPadD;                // destination bitmap horizontal padding to DWORD
            pcImgS=pcImg+(ixHeight*3);    // reset the source to the begining of the next vertical line
        }    
    }
#else    // __USE_MASM__
    nBmpWdtPS-=4;                    // adjust esi increment (due to esi self-incrementing by movsd)
    nWidth=szBmp.cx;
    __asm
    {        mov        esi, pcImg            // source index
    mov        edi, pcImgRotate    // destination index
    xor        ebx, ebx            // vertical counter
loop_height:
    mov        ecx, nWidth            // horizontal counter
        cmp        ebx, nHeight1        // check is it the last line
        jne        loop_width
        dec        ecx                    // if it is decremnt for the last pixel

loop_width:
    movsd                        // copies 4 bytes and increments source and destination by 4 (we need only 3 bytes copied 'one pixel' RGB triplet)
        dec        edi                    // adjust edi to 'as incremented by 3'
        add        esi,nBmpWdtPS        // adjust esi to the next source line
        loop    loop_width            // loop one hotizontal destination line 

        cmp        ebx, nHeight1        // check is it the last line
        je        do_last                // if not last, do incrementing here

        inc        ebx                    // increment vertical counter
        add        edi, nPadD            // adjust destination index by possible padding to DWORD
        mov        esi, ebx            // reset the source index: add vertical counter * 3 
        shl        esi, 1                // (is the same as * 2 +1*)
        add        esi, ebx            // +1*
        add        esi, pcImg            // add to the beginning of the source
        jmp        loop_height            // loop whole height

do_last:                        // the last pixel is done by
    movsw                        // moving first two bytes
        movsb                        // and than by moving the very last byte
    }
#endif //     __USE_MASM__
    dcMem.SelectObject(pBmpOld); bmpMem.DeleteObject();        // recreate rotated bitmap
    bmpMem.CreateCompatibleBitmap(pDC,szBmp.cx,szBmp.cy);
    dcMem.SelectObject(&bmpMem);
    bihOut.biWidth =szBmp.cx; bihOut.biHeight=bBody?-szBmp.cy:szBmp.cy;
    SetDIBits(*pDC, bmpMem.operator HBITMAP(),0,szBmp.cy,pcImgRotate,&biOut,DIB_RGB_COLORS); // set rotated bitmap bits
    delete pcImgRotate;
    }
    if(pcImg) delete pcImg;
    // 6th blit mirrored/rotated image to the screen
    pDC->BitBlt(rcItem.left,rcItem.top,szBmp.cx,szBmp.cy,&dcMem,0,0,SRCCOPY); // 
    dcMem.SelectObject(pBmpOld);
}