2011-04-16 18:41:34|?次阅读|上传:wustguangh【已有?条评论】发表评论
关键词:C/C++, MFC, 图形/图像|来源:唯设编程网
//输出文本和图形 void CTestSaveBmpView::DrawCurve(CDC *pDC, CRect rcClient) { //页面背景色 CBrush brushCtl; brushCtl.CreateSolidBrush(RGB(255,255,255)); pDC->Rectangle(rcClient); pDC->FillRect(rcClient,&brushCtl) ; brushCtl.DeleteObject(); CPen pen; pen.CreatePen(PS_SOLID, 1, RGB(255,0,0)); CPen *oldPen = pDC->SelectObject(&pen); double xMin = 10.00f, xMax = 100.00f; double yMin = 10.00f, yMax = 200.00f; double dbX1 = (xMax- xMin)/100 xMin; double dbY1 = 600/dbX1 ; for (int i=1; i<100; i ) //曲线 { double dbX2 = (xMax- xMin)*i/100 xMin; double dbY2 = 600/dbX2 ; pDC->MoveTo(int(rcClient.left (dbX1 - xMin)*rcClient.Width()/(xMax- xMin)); int(rcClient.bottom-(dbY1- yMin)*rcClient.Height()/(yMax- yMin))); pDC->LineTo(int(rcClient.left (dbX2 - xMin)*rcClient.Width()/(xMax- xMin)); int(rcClient.bottom-(dbY2- yMin)*rcClient.Height()/(yMax- yMin))); dbX1=dbX2; dbY1=dbY2; } pDC->SelectObject(oldPen); pen.DeleteObject(); oldPen = NULL; } //保存的实现 void CTestSaveBmpView::OnRButtonDown(UINT nFlags, CPoint point) { CFileDialog dlg(false,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "位图文件(*.bmp)|*.bmp|", NULL); if (dlg.DoModal()!= IDOK) return; CString filename = dlg.GetFileName() ".bmp"; SaveAsBmp(filename); CView::OnRButtonDown(nFlags, point); }