Ejemplo n.º 1
1
void COutlook2Ctrl::AnimateToFolder(int f)
{
	m_iSelectedFolder = f;
 	pLastHilink = NULL;
	m_csCaption = GetFolder(f)->csName;

	if (m_iSize > 4)
	{

		CRect rc;
		GetClientRect(rc);

		CDC dc;
		CClientDC cdc(this);
		dc.CreateCompatibleDC(&cdc);
		CBitmap bmp;
		bmp.CreateCompatibleBitmap(&cdc, rc.Width(), rc.Height());
		CBitmap * ob = (CBitmap *) dc.SelectObject(&bmp);

		DrawCaption(&dc, rc);
		CRect rcBdr(rc);
		rc.InflateRect(-1,-1);
		DrawButtons(&dc, rc);
		int iBottomInner = rc.bottom;
		dc.Draw3dRect(rcBdr, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
		rcInnerRect = rc;
		dc.FillSolidRect(rc, m_crBackground);
		if (m_iSelectedFolder >= 0 && m_iSelectedFolder < m_Folders.GetSize())
		{
			COL2Folder * o = (COL2Folder *) m_Folders.GetAt(m_iSelectedFolder);
			DrawItems(&dc, o, rc);
		}

		for (int t = iBottomInner - 10; t > 0; t -= (iBottomInner/8))
		{
			cdc.BitBlt(0,t,rc.Width(), iBottomInner - t, &dc, 0,0, SRCCOPY);
			Sleep(30);
		}
		dc.SelectObject(ob);
	}

	Invalidate();
}
CostPair GraphicsCostEstimator::estimateDrawCost(const osg::Node* node) const
{
    if (!node) return CostPair(0.0,0.0);
    CollectDrawCosts cdc(this);
    const_cast<osg::Node*>(node)->accept(cdc);
    return cdc._costs;
}
Ejemplo n.º 3
0
BOOL TChart::Create(CWnd* pParentWnd,const RECT& rect)
{
	BOOL ret; void *x;
	CClientDC cdc(pParentWnd); 
	ret=CWnd::Create(0, Name, WS_CHILD | WS_BORDER, rect, pParentWnd, ID_CHART, 0);	

	font1.CreatePointFont(60,"MS Sans Serif");			
	font2.CreatePointFont(100,"Arial"); 

	if((x=Series.GainAcsess(WRITE))!=NULL)
	{
		SeriesProtector guard(x); TSeriesArray& series(guard);
		series.Parent=this;
		series.Parent=this;
		series.SetRender(SERIES_RENDER);
	}
	SetFont(&font1);
	menu1.LoadMenu(IDR_MENU2);
    OnPaintTimer.Start();	

	pThrd=AfxGetThread();	pWND=this;
	BckgBrush.CreateSolidBrush(RGB(140,140,140));
	InitBasicElements();
	OnSeriesUpdate(0,0);
	return ret;
}
Ejemplo n.º 4
0
void RenderCanvas::OnNewPixel( wxCommandEvent& event )
{
   //set up double buffered device context
   wxClientDC cdc(this);
   DoPrepareDC(cdc);
   wxBufferedDC bufferedDC(&cdc, *m_image);
   
   //iterate over all pixels in the event
   vector<RenderPixel*> *pixelsUpdate =
                        (vector<RenderPixel*> *)event.GetClientData();
   
   for(vector<RenderPixel*>::iterator itr = pixelsUpdate->begin();
                        itr != pixelsUpdate->end(); itr++)
   {
      RenderPixel* pixel = *itr;
      
      wxPen pen(wxColour(pixel->red, pixel->green, pixel->blue));
      bufferedDC.SetPen(pen);
      bufferedDC.DrawPoint(pixel->x, pixel->y);
     
      pixelsRendered++;
      delete pixel;
   }
   
   pixelsUpdate->clear();
   delete pixelsUpdate;
}
Ejemplo n.º 5
0
void CDebug::run() {
	if ( m_port==DBG_USB ) {
		//
		// USB port
		//
		CSerial cdc(USB);
		m_shell.assign(cdc);
		while(1) {
			if ( cdc.isConnected() ) {
				m_shell.run();
			}
		}

	} else {
		//
		// Telnet (TCP/IP port 23)
		//
		CSocket server;
		CSocket *client;

		server.create(SOCK_STREAM);
		server.bind(TELNET_PORT);
		server.listen();
		while (1) {
			if ((client = server.accept()) != NULL) {
				client->keepAlive(3, 3, 3);	// set keep alive in 3 seconds for idle, try in 3 seconds and 3 times
				m_shell.assign(client);
				m_shell.run();
				delete client;
			}
		}
	}
}
Ejemplo n.º 6
0
void Bitmap::create(int w, int h, bool _alpha) {
  free();

  checkSize(w, h);
  
  BITMAPINFO bmi;
  ZeroMemory(&bmi, sizeof(BITMAPINFO));
  bmi.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
  bmi.bmiHeader.biWidth       = w;
  bmi.bmiHeader.biHeight      = h;
  bmi.bmiHeader.biPlanes      = 1;
  bmi.bmiHeader.biBitCount    = 32; 
  bmi.bmiHeader.biCompression = BI_RGB;
  bmi.bmiHeader.biSizeImage   = bmi.bmiHeader.biWidth * bmi.bmiHeader.biHeight * 4;

  DCDisplay dcd;
  DCCompatible cdc(dcd.hdc);

  ptr32 = 0;
  handle = CreateDIBSection(cdc.hdc, &bmi, DIB_RGB_COLORS, &ptr32, NULL, 0x0);
  if(handle==0) raise_os(_T("Bitmap.create: CreateDIBSection"));
  if(ptr32==0) { DeleteObject(handle); handle=0; raise(_T("Bitmap.create: CreateDIBSection ptr32=0")); }

  BEGIN_NO_EXCEPTION
    width  = w;
    height = h;
    alpha  = _alpha;
  END_NO_EXCEPTION
}
Ejemplo n.º 7
0
void RolloverWin::SetBestPosition( int x, int y, int off_x, int off_y, int rollover,
                                   wxSize parent_size )
{
    int h, w;

    wxFont *dFont;
    switch( rollover ) {

    case AIS_ROLLOVER:
        dFont = FontMgr::Get().GetFont( _("AISRollover"), 12 );
        break;

    case TC_ROLLOVER:
        dFont = FontMgr::Get().GetFont( _("TideCurrentGraphRollover"), 12 );
        break;

    default:
    case LEG_ROLLOVER:
        dFont = FontMgr::Get().GetFont( _("RouteLegInfoRollover"), 12 );
        break;

    }

    int font_size = wxMax(8, dFont->GetPointSize());
    m_plabelFont = wxTheFontList->FindOrCreateFont( font_size, dFont->GetFamily(),
                         dFont->GetStyle(), dFont->GetWeight(), false, dFont->GetFaceName() );

    if(m_plabelFont && m_plabelFont->IsOk()) {
#ifdef __WXMAC__
        wxScreenDC sdc;
        sdc.GetMultiLineTextExtent(m_string, &w, &h, NULL, m_plabelFont);
#else
        wxClientDC cdc( GetParent() );
        cdc.GetMultiLineTextExtent( m_string, &w, &h, NULL, m_plabelFont );
#endif
    }
    else {
        w = 10;
        h = 10;
    }

    m_size.x = w + 8;
    m_size.y = h + 8;

    int xp, yp;
    if( ( x + off_x + m_size.x ) > parent_size.x ) {
        xp = x - ( off_x / 2 ) - m_size.x;
        xp = wxMax(0, xp);
    } else
        xp = x + off_x;

    if( ( y + off_y + m_size.y ) > parent_size.y ) {
        yp = y - ( off_y / 2 ) - m_size.y;
    } else
        yp = y + off_y;

    SetPosition( wxPoint( xp, yp ) );

}
Ejemplo n.º 8
0
  icon::icon(ID2D1BitmapPtr& ptr)
  {
    ID2D1FactoryPtr factory;
    ptr->GetFactory(&factory);

    D2D1_SIZE_U size(ptr->GetPixelSize());
    // ビットマップヘッダのセットアップ
    BITMAPV5HEADER bi = {0};
    bi.bV5Size           = sizeof(BITMAPV5HEADER);
    bi.bV5Width           = size.width;
    bi.bV5Height          = size.height;
    bi.bV5Planes = 1;
    bi.bV5BitCount = 32;
    bi.bV5Compression = BI_BITFIELDS;
    bi.bV5RedMask   =  0x00FF0000;
    bi.bV5GreenMask =  0x0000FF00;
    bi.bV5BlueMask  =  0x000000FF;
    bi.bV5AlphaMask =  0xFF000000; 

    // デスクトップHDCの取得
    get_dc dc(NULL);
    
    // DIBセクションの作成
    void *bits;// 得られるビットマップ
    bitmap_holder bmp(
      ::CreateDIBSection(
        dc.get(),reinterpret_cast<BITMAPINFO *>(&bi),DIB_RGB_COLORS,&bits,NULL,0));
    { 
      // 互換DCの作成
      compatible_dc cdc(dc.get());
      {
        // 描画先への切り替え
        select_object s(cdc.get(),bmp.get());

        // DC互換レンダーターゲットのセットアップ
        D2D1_RENDER_TARGET_PROPERTIES 
          props = D2D1::RenderTargetProperties(
          D2D1_RENDER_TARGET_TYPE_DEFAULT,
          D2D1::PixelFormat(
              DXGI_FORMAT_B8G8R8A8_UNORM,
              D2D1_ALPHA_MODE_PREMULTIPLIED),
          0,
          0,
          D2D1_RENDER_TARGET_USAGE_NONE,
          D2D1_FEATURE_LEVEL_DEFAULT
        );

        ID2D1DCRenderTargetPtr dcr;
        throw_if_err<>()(factory->CreateDCRenderTarget(&props,dcr.GetAddressOf()));
        RECT rect = {0,0,size.width,size.height};
        // 互換DCへのバインド
        throw_if_err<>()(dcr->BindDC(cdc.get(),&rect));
        dcr->DrawBitmap(ptr.Get());
      }
    }
    icon(bmp,size.width,size.height);
  };
Ejemplo n.º 9
0
TEST(CSSTokenizerTest, MultipleCharacterTokens)
{
    TEST_TOKENS("~=", includeMatch());
    TEST_TOKENS("|=", dashMatch());
    TEST_TOKENS("^=", prefixMatch());
    TEST_TOKENS("$=", suffixMatch());
    TEST_TOKENS("*=", substringMatch());
    TEST_TOKENS("||", column());
    TEST_TOKENS("|||", column(), delim('|'));
    TEST_TOKENS("<!--", cdo());
    TEST_TOKENS("<!---", cdo(), delim('-'));
    TEST_TOKENS("-->", cdc());
}
Ejemplo n.º 10
0
LRESULT CVideoViewControl::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	PAINTSTRUCT ps = { 0 };
	CDCHandle cdc(BeginPaint(&ps));

	if (m_bPlayerStarted && m_strLastErrorMsg.IsEmpty())
	{
		::SendMessage(m_hWndPlayer, WM_PLAYER_UPDATE, 0, 0);
	}
	else
	{
		CRect rect;
		GetClientRect(&rect);

		static DWORD dwBrushColor = 0;
		static DWORD dwTextColor = 0;
		if (!dwBrushColor)
		{
			CComPtr<IThemeColorMap> pThemeColorMap;
			ASSERT_IF_FAILED(m_pTheme->GetColorMap(&pThemeColorMap));
			ASSERT_IF_FAILED(pThemeColorMap->GetColor(Twitter::Metadata::Drawing::BrushBackground, &dwBrushColor));
			ASSERT_IF_FAILED(pThemeColorMap->GetColor(Twitter::Metadata::Drawing::PictureWindowText, &dwTextColor));
		}

		cdc.SetBkMode(TRANSPARENT);
		cdc.SetTextColor(dwTextColor);

		cdc.FillSolidRect(&rect, dwBrushColor);

		CComBSTR str = L"Launching video player...";
		if (!m_strLastErrorMsg.IsEmpty())
			str = m_strLastErrorMsg;

		CSize size;
		CRect rect1 = rect;
		cdc.DrawTextEx(str, str.Length(), &rect1, DT_WORDBREAK | DT_CENTER | DT_CALCRECT, NULL);
		size.cx = rect1.Width();
		size.cy = rect1.Height();

		auto x = (rect.right - rect.left) / 2 - (size.cx / 2);
		auto y = (rect.bottom - rect.top) / 2 - (size.cy / 2);

		CRect rectText(x, y, x + size.cx, y + size.cy);
		DrawRoundedRect(cdc, rectText, false);
		cdc.DrawTextEx(str, str.Length(), &rectText, DT_WORDBREAK | DT_CENTER, NULL);
	}
	EndPaint(&ps);
	return 0;
}
Ejemplo n.º 11
0
bool BitmapFromWindow(wxWindow *window, wxBitmap& bitmap)
{
    bool ret;
    wxMemoryDC mdc;
    wxClientDC cdc(window);
    const wxSize& size=window->GetClientSize();

    window->Raise();
    wxTheApp->Yield();

    bitmap.Create(size.x, size.y);
    mdc.SelectObject(bitmap);
    ret=mdc.Blit(0, 0, size.x, size.y, &cdc, 0, 0);
    mdc.SelectObject(wxNullBitmap);

    return ret;
}
Ejemplo n.º 12
0
BOOL CDIBitmap :: LoadResource(LPCTSTR pszID) {
	HBITMAP hBmp = (HBITMAP)::LoadImage(
						AfxGetInstanceHandle(), 
						pszID, IMAGE_BITMAP,
						0,0, LR_CREATEDIBSECTION
					);

	if( hBmp == 0 ) 
		return FALSE;

	CBitmap bmp;
	bmp.Attach(hBmp);
	CClientDC cdc( CWnd::GetDesktopWindow() );
	BOOL bRet = CreateFromBitmap( &cdc, &bmp );
	bmp.DeleteObject();
	return bRet;
}
void C多播收发:刘兴龙Dlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // 用于绘制的设备上下文

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// 使图标在工作区矩形中居中
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// 绘制图标
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		//加载位图  
		CBitmap bitmap;
		bitmap.LoadBitmap(IDB_BITMAP1);

		//选入DC  
		CClientDC cdc(this);
		CDC comdc;
		comdc.CreateCompatibleDC(&cdc);
		comdc.SelectObject(&bitmap);

		//生成BITMAP  
		BITMAP bit;
		bitmap.GetBitmap(&bit);

		//客户区域  
		CRect rect;
		GetClientRect(rect);

		//用客户区的DC绘制所生成的BITMAP,并适应为窗口大小  
		cdc.StretchBlt(0, 0, rect.Width(), rect.Height(), &comdc, 0, 0, bit.bmWidth, bit.bmHeight, SRCCOPY);
		CDialogEx::OnPaint();
	}	
}
Ejemplo n.º 14
0
void RenderCanvas::OnNewPixel( wxCommandEvent& event ) {
    //set up double buffered device context
    wxClientDC cdc(this);
    DoPrepareDC(cdc);
    wxBufferedDC bufferedDC(&cdc, *m_image);

    //iterate over all pixels in the event
    RenderPixels *pixelsUpdate =
        (RenderPixels *)event.GetClientData();

    for (RenderPixels::iterator itr = pixelsUpdate->begin();
            itr != pixelsUpdate->end(); ++itr) {
        RenderPixel& pixel = *itr;

        wxPen pen(wxColour(pixel.red, pixel.green, pixel.blue));
        bufferedDC.SetPen(pen);
        bufferedDC.DrawPoint(pixel.x, pixel.y);

        pixelsRendered++;
    }

    delete pixelsUpdate;
}
Ejemplo n.º 15
0
void CImgClassCBView::LoadThumbNail0()
{
	CMainFrame* pFrame=(CMainFrame*)AfxGetMainWnd();
	CImgClassCBView* pView0;
	CImgClassCBDoc* pDoc0;
	pView0 = pFrame->m_pTrainView;
	pDoc0 = pView0->GetDocument();

	CListCtrl& ListCtrl0=pView0->GetListCtrl();
	CImageList* pImgList0 = &pView0->m_ImageListThumb;
	
	int i;
	// reset our image list
	for(i=0; i<pImgList0->GetImageCount(); i++)
		pImgList0->Remove(i);	

	// remove all items from list view
	ListCtrl0.DeleteAllItems();

	pImgList0->SetImageCount(pDoc0->m_vImgNameTrain.size());

	TCHAR path0[MAX_PATH];
	vector<CString>::iterator iter0;
	
	// Set redraw to FALSE to avoid flickering during adding new items
	ListCtrl0.SetRedraw(FALSE);

	int nIndex0 = 0;
	for(iter0=pDoc0->m_vImgNameTrain.begin(); 
		iter0 != pDoc0->m_vImgNameTrain.end(); 
		iter0 ++, nIndex0 ++)
	{
		ListCtrl0.InsertItem(nIndex0, *iter0, nIndex0);
	}

	ListCtrl0.SetRedraw(TRUE);
	ListCtrl0.Invalidate();
	// Create Brushes for Border and BackGround
	HBRUSH hBrushBorder=::CreateSolidBrush(RGB(192, 192, 192));
	HBRUSH hBrushBk=::CreateSolidBrush(RGB(255, 255, 255));

	// Border Size
	RECT rcBorder;
	rcBorder.left=rcBorder.top=0;
	rcBorder.right=THUMBNAIL_WIDTH;
	rcBorder.bottom=THUMBNAIL_HEIGHT;

	const float fRatio=(float)THUMBNAIL_HEIGHT/THUMBNAIL_WIDTH;

	int XDest, YDest, nDestWidth, nDestHeight;
	nIndex0=0;
	for(iter0=pDoc0->m_vImgNameTrain.begin();
		iter0!=pDoc0->m_vImgNameTrain.end();
		iter0++, nIndex0++)
	{
		// Load Image File
		_stprintf(path0, _T("%s\\%s"), pDoc0->m_strCurrentDirectory, *iter0);
		
		int nImageType=pDoc0->GetTypeFromFileName(path0);
		if(nImageType==CXIMAGE_FORMAT_UNKNOWN)
			continue;
		
		CxImage image(path0, nImageType);
		
		if(image.IsValid()==false)
			continue;
		
		// Calculate Rect to fit to canvas
		const float fImgRatio=(float)image.GetHeight()/image.GetWidth();
		if(fImgRatio > fRatio)
		{
			nDestWidth=THUMBNAIL_HEIGHT/fImgRatio;
			XDest=(THUMBNAIL_WIDTH-nDestWidth)/2;
			YDest=0;
			nDestHeight=THUMBNAIL_HEIGHT;
		}
		else
		{
			XDest=0;
			nDestWidth=THUMBNAIL_WIDTH;
			nDestHeight=THUMBNAIL_WIDTH*fImgRatio;
			YDest=(THUMBNAIL_HEIGHT-nDestHeight)/2;
		}
		
		CClientDC cdc(pView0);
		HDC hDC=::CreateCompatibleDC(cdc.m_hDC);
		HBITMAP bm = CreateCompatibleBitmap(cdc.m_hDC, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
		HBITMAP pOldBitmapImage = (HBITMAP)SelectObject(hDC,bm);
		// Draw Background
		::FillRect(hDC, &rcBorder, hBrushBk);
		
		// Draw Image
		image.Stretch(hDC, XDest, YDest, nDestWidth, nDestHeight);
		
		// Draw Border
		::FrameRect(hDC, &rcBorder, hBrushBorder);
		
		SelectObject(hDC, pOldBitmapImage);
		
		// Attach to Bitmap and Replace image in CImageList
		CBitmap bitmap;
		bitmap.Attach(bm);
		pImgList0->Replace(nIndex0, &bitmap, NULL);
		
		// Redraw only a current item for removing flickering and fast speed.
		ListCtrl0.RedrawItems(nIndex0, nIndex0);
		
		// Release used DC and Object
		DeleteDC(hDC);
		DeleteObject(bm);
	}
	DeleteObject(hBrushBorder);
	DeleteObject(hBrushBk);
	
	ListCtrl0.Invalidate();
}
Ejemplo n.º 16
0
void CImgClassCBView::LoadThumbNail1(int iCls, bool bCorrect[], int iImgs_per_Cls[])
{
	CMainFrame* pFrame=(CMainFrame*)AfxGetMainWnd();
	CImgClassCBView* pView1;
	CImgClassCBDoc* pDoc1;
	pView1 = pFrame->m_pTestView;
	pDoc1 = pView1->GetDocument();
	CListCtrl& ListCtrl1=pView1->GetListCtrl();
	CImageList* pImgList1 = &pView1->m_ImageListThumb;
	int i;
	for(i=0; i<pImgList1->GetImageCount(); i++)
		pImgList1->Remove(i);	
	ListCtrl1.DeleteAllItems();
	pImgList1->SetImageCount(pDoc1->m_vImgNameTest.size());
	TCHAR path1[MAX_PATH];
	vector<CString>::iterator iter1;
	ListCtrl1.SetRedraw(FALSE);
	int nIndex1 = 0;
	for(iter1=pDoc1->m_vImgNameTest.begin(); 
			iter1!=pDoc1->m_vImgNameTest.end();
			iter1++, nIndex1++)
	{
		ListCtrl1.InsertItem(nIndex1, *iter1, nIndex1);
	}
	ListCtrl1.SetRedraw(TRUE);
	ListCtrl1.Invalidate();
	
	//Load Error Tag Img:
	CString szErrTag = "res\\err.png";
	CString szCorTag = "res\\cor.png";
	TCHAR path[MAX_PATH]={0};
	_stprintf(path, _T("%s"),szErrTag.GetBuffer(0));
	int nImageTypeErr=pDoc1->GetTypeFromFileName(path);
	CxImage imageErr(path, nImageTypeErr);
	_stprintf(path, _T("%s"),szCorTag.GetBuffer(0));
	nImageTypeErr=pDoc1->GetTypeFromFileName(path);
	CxImage imageCor(path, nImageTypeErr);
	if(imageErr.IsValid()==false || imageErr.IsValid()==false )
	{
		return;
	}
	////////////////////

	HBRUSH hBrushBorder=::CreateSolidBrush(RGB(192, 192, 192));
	HBRUSH hBrushBk=::CreateSolidBrush(RGB(255, 255, 255));
	
	// Border Size
	RECT rcBorder;
	rcBorder.left=rcBorder.top=0;
	rcBorder.right=THUMBNAIL_WIDTH;
	rcBorder.bottom=THUMBNAIL_HEIGHT;
	
	const float fRatio=(float)THUMBNAIL_HEIGHT/THUMBNAIL_WIDTH;
	
	int XDest, YDest, nDestWidth, nDestHeight;
	
	nIndex1=0;

	for(iter1 = pDoc1->m_vImgNameTest.begin();
		iter1 != pDoc1->m_vImgNameTest.end(); 
		iter1 ++, nIndex1 ++)
	{
		// Load Image File
		_stprintf(path1, _T("%s\\%s"), pDoc1->m_strCurrentDirectory, *iter1);
		
		int nImageType=pDoc1->GetTypeFromFileName(path1);
		if(nImageType==CXIMAGE_FORMAT_UNKNOWN)
			continue;
		
		CxImage image(path1, nImageType);
		
		if(image.IsValid()==false)
			continue;
		
		// Calculate Rect to fit to canvas
		const float fImgRatio=(float)image.GetHeight()/image.GetWidth();
		if(fImgRatio > fRatio)
		{
			nDestWidth=THUMBNAIL_HEIGHT/fImgRatio;
			XDest=(THUMBNAIL_WIDTH-nDestWidth)/2;
			YDest=0;
			nDestHeight=THUMBNAIL_HEIGHT;
		}
		else
		{
			XDest=0;
			nDestWidth=THUMBNAIL_WIDTH;
			nDestHeight=THUMBNAIL_WIDTH*fImgRatio;
			YDest=(THUMBNAIL_HEIGHT-nDestHeight)/2;
		}
		
		//HBRUSH hBrushBorder=::CreateSolidBrush(RGB(192, 1, 192));
		//HBRUSH hBrushBk=::CreateSolidBrush(RGB(255, 255, 255));
		HBRUSH hBrushBkErr=::CreateSolidBrush(RGB(155, 0, 0));
		HBRUSH hBrushBkCor=::CreateSolidBrush(RGB(0, 190, 0));
		CClientDC cdc(pView1);
		HDC hDC=::CreateCompatibleDC(cdc.m_hDC);
        //建立与pView显示设备兼容的位图
		HBITMAP bm = CreateCompatibleBitmap(cdc.m_hDC, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
        //HBITMAP bm2 = CreateCompatibleBitmap(cdc.m_hDC, THUMBNAIL_WIDTH_MASK, THUMBNAIL_HEIGHT_MASK);
		HBITMAP pOldBitmapImage = (HBITMAP)SelectObject(hDC,bm);
		// Draw Background

		::FillRect(hDC, &rcBorder, hBrushBk);
		//::FillRect(hDC, &rcBorderInside, hBrushBk);
		
		// Draw Image
		image.Stretch(hDC, XDest + 2, YDest + 2, nDestWidth - 4, nDestHeight - 4);
		
		// Draw Border
		//::FrameRect(hDC, &rcBorderInside, hBrushBorder);
		
		SelectObject(hDC, pOldBitmapImage);
		
		// Attach to Bitmap and Replace image in CImageList
		CBitmap bitmap;
		bitmap.Attach(bm);
		pImgList1->Replace(nIndex1, &bitmap, NULL);
		
		// Redraw only a current item for removing flickering and fast speed.
		ListCtrl1.RedrawItems(nIndex1, nIndex1);
		
		///////////////////////////////////////////////////////////////////////////
		//对标号不对的图片进行标记(正确的打对号)
		CxImage *pImg;
		int iImgNo = iImgs_per_Cls[nIndex1];
		if(!bCorrect[iImgNo / 100 * 50 + iImgNo % 50])
			pImg = &imageErr;
		else pImg = &imageCor;
		HBITMAP bmErr = CreateCompatibleBitmap(cdc.m_hDC, THUMBNAIL_WIDTH_MASK, THUMBNAIL_HEIGHT_MASK);
		HBITMAP pOldBitmapImageErr = (HBITMAP)SelectObject(hDC,bmErr);
		::FillRect(hDC, &rcBorder, hBrushBk);
		pImg->AlphaSet(100); 
		pImg->Stretch(hDC, 0, 0, THUMBNAIL_WIDTH_MASK, THUMBNAIL_HEIGHT_MASK);
		SelectObject(hDC, pOldBitmapImage);
		CBitmap bitmapErr;
		bitmapErr.Attach(bmErr);//将位图贴到ImageList控件上
		pImgList1->Replace(nIndex1, &bitmapErr, NULL);
		pImgList1->SetOverlayImage(nIndex1,1);
		CPoint myPoint(XDest,YDest);
		pImgList1->Draw((CDC*)&hDC, 0, myPoint, INDEXTOOVERLAYMASK(1));
		ListCtrl1.RedrawItems(nIndex1, nIndex1);
		DeleteObject(bmErr);

///////////////////////////////////////////////////////////////////////////

		// Release used DC and Object
		DeleteDC(hDC);
		DeleteObject(bm);
		DeleteObject(hBrushBkErr);
		DeleteObject(hBrushBkCor);
	}
	DeleteObject(hBrushBorder);
	DeleteObject(hBrushBk);

	ListCtrl1.Invalidate();

	return;
}
Ejemplo n.º 17
0
void ArtWindow::OnPaint(HDC dc)
{
	CPaintDC cdc(*this);
	renderer->Render(cdc);
}
Ejemplo n.º 18
0
void CImgClassCBView::SetErrorImgTag(int nIndex)
{
    //从CImageList中恢复图片
	CMainFrame* pFrame=(CMainFrame*)AfxGetMainWnd();
	CImgClassCBView* pView = pFrame->m_pTestView;
	CImgClassCBDoc*  pDoc = pView->GetDocument();
    
	CListCtrl& ListCtrl=pView->GetListCtrl();
	CImageList* pImgList=&pView->m_ImageListThumb;
	
	
	//vector<CString>::iterator iter;
	
	// Create Brushes for Border and BackGround
	HBRUSH hBrushBorder=::CreateSolidBrush(RGB(192, 192, 192));
	HBRUSH hBrushBk=::CreateSolidBrush(RGB(255, 255, 255));//背景是黑色
	
	// Border Size
	RECT rcBorder;
	rcBorder.left=rcBorder.top=0;
	rcBorder.right=THUMBNAIL_WIDTH_MASK;
	rcBorder.bottom=THUMBNAIL_HEIGHT_MASK;
	
	const float fRatio=(float)THUMBNAIL_HEIGHT_MASK/THUMBNAIL_WIDTH_MASK;
	
	int XDest, YDest, nDestWidth, nDestHeight;
	//Set redraw to FALSE to avoid flickering during adding new items
	//ListCtrl.SetRedraw(FALSE);
	// Load Image File
	//_stprintf(path, _T("%s"),PATH_REMOVE_BMP);
	//这里要写函数得到当前目录
	CString szErrTag = "G:\\err.png";
	
	TCHAR path[MAX_PATH]={0};
	_stprintf(path, _T("%s"),szErrTag.GetBuffer(0));
	
	int nImageType=pDoc->GetTypeFromFileName(path);
	CxImage image(path, nImageType);
	if(image.IsValid()==false)
	{
		return ;
	}
	//Calculate Rect to fit to canvas
	const float fImgRatio=(float)image.GetHeight()/image.GetWidth();
	if(fImgRatio > fRatio)
	{
		nDestWidth=THUMBNAIL_HEIGHT_MASK/fImgRatio;
		XDest=(THUMBNAIL_WIDTH_MASK-nDestWidth)/2;
		YDest=0;
		nDestHeight=THUMBNAIL_HEIGHT_MASK;
	}
	else
	{
		XDest=0;
		nDestWidth=THUMBNAIL_WIDTH_MASK;
		nDestHeight=THUMBNAIL_WIDTH_MASK*fImgRatio;
		YDest=(THUMBNAIL_HEIGHT_MASK-nDestHeight)/2;
	}
	
	
// 	AfxMessageBox("woat!");
	CClientDC cdc(pView);//定义pView为显示设备对象
	HDC hDC=::CreateCompatibleDC(cdc.m_hDC);//建立与pView显示设备兼容的内存显示设备
	//建立与pView显示设备兼容的位图
	HBITMAP bm = CreateCompatibleBitmap(cdc.m_hDC, THUMBNAIL_WIDTH_MASK, THUMBNAIL_HEIGHT_MASK);
	//将位图选入到pView显示设备中
	HBITMAP pOldBitmapImage = (HBITMAP)SelectObject(hDC,bm);
	// Draw Background
	//使用背景色将位图清除干净
	::FillRect(hDC, &rcBorder, hBrushBk);
	// Draw Image
	//将图片画在pView内存显示设备上
	image.AlphaSet(100); 
	image.Stretch(hDC, XDest, YDest, nDestWidth, nDestHeight);
	// Draw Border
	//在内存显示设备上画边框
	::FrameRect(hDC, &rcBorder, hBrushBorder);
	//将位图图像显示到pView显示设备上
	SelectObject(hDC, pOldBitmapImage);
	// Attach to Bitmap and Replace image in CImageList
	CBitmap bitmap;
	bitmap.Attach(bm);//将位图贴到ImageList控件上
	pImgList->Replace(nIndex, &bitmap, NULL);
	//这里需要再贴一张透明的图片在原始的图片上...........
	//pImgList->SetOverlayImage(nIndex,1);
	//CPoint myPoint(XDest,YDest);
	//pImgList->Draw((CDC*)&hDC, 0, myPoint, INDEXTOOVERLAYMASK(1));
	// Redraw only a current item for removing flickering and fast speed.
	ListCtrl.RedrawItems(nIndex, nIndex);
	// Release used DC and Object
	DeleteDC(hDC);
	DeleteObject(bm);
	
	
	DeleteObject(hBrushBorder);
	DeleteObject(hBrushBk);
}
Ejemplo n.º 19
0
void CPhotoPubView::OnTimer(UINT_PTR nIDEvent)
{
	KillTimer(1);
	CPhotoPubDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	// TODO: Add your message handler code here and/or call default
	int nFiles=m_CurFiles.size();
	set<CString> CurFiles1;
	const int nFiles1=GetAllFolderFile(m_WatchingPath, "*.jpg", CurFiles1);
	if (nFiles==nFiles1) {
		SetTimer(1,500,NULL);
		return;
	}else if (nFiles>nFiles1){
		AfxMessageBox("同步发生错误,无法恢复,请重新运行!\n");
		exit(1);
	}
	
	//Here Comes a new Photo
	//wait transfering
	Sleep(1000);
	//process
	set<CString>::iterator it1;
	for (it1=CurFiles1.begin();it1!=CurFiles1.end();++it1)
	{
		if ( m_CurFiles.find(*it1)==m_CurFiles.end() ) //not exist before
		{
			((CMainFrame*)GetParent())->ShowWindow(SW_SHOWMAXIMIZED);

			CClientDC cdc(this);
			CRect clrct;
			GetClientRect(&clrct);
			int width=clrct.Width();
			int height=clrct.Height();

			if (pDoc->m_pOpenedImage) ReleaseFImage(&pDoc->m_pOpenedImage);
			IplImage *pImg=pDoc->m_pOpenedImage=LoadFImage(m_WatchingPath+"\\"+*it1+".jpg");
			m_ratio=min(double(width)/pImg->width,double(height)/pImg->height);
			((CMainFrame*)GetParent())->SetRatio(int(m_ratio*100));
			OnUpdate(NULL,NULL,NULL);
			DrawImage(&cdc,pImg);

			CString newname;
			int res;
			do {
				GetNewName(m_InitStr,newname);
				res=rename(m_WatchingPath+"\\"+*it1+".jpg",m_WatchingPath+"\\"+newname+".jpg");
			}while( 
				(res==0) ? false : (true,
					(errno==EEXIST) ? AfxMessageBox("文件名重复!请重试"): (
						(errno==EINVAL) ? AfxMessageBox("文件名含非法字符!请重试"):AfxMessageBox("未知错误!请重试")
				) ) );
			m_CurFiles.insert(newname);
			m_InitStr=newname;
			CStringNumber snum(m_InitStr);
			snum.Increase();
			snum.ToString(m_InitStr);
			//break;
		}
	}
	
	CScrollView::OnTimer(nIDEvent);

	SetTimer(1,500,NULL);
}