vc mfc 打印模式是 2 的时候,只有一条黑线,是怎么回事?

大漠飞狐 2016-12-03 11:06:53

pDC->SetMapMode(2);//----------------------------------
CDC memDC;
CBitmap bitmap;
//CDC* pImageDC;
memDC.CreateCompatibleDC(NULL);
memDC.SetMapMode(2);//----------------------------------------
CBitmap *pOldBmp;
if (bitmap.GetSafeHandle() != nullptr)
bitmap.DeleteObject();

bitmap.CreateCompatibleBitmap(pDC, 500, 500);
pOldBmp = memDC.SelectObject(&bitmap);
memDC.FillSolidRect(0, 0, 500, 500, RGB(200,2,2));
//pDC->BitBlt(10, 10, 500, 500, &memDC, 0, 0, SRCCOPY);
pDC->BitBlt(500, -500, 500, 500, &memDC, 0, 0, SRCCOPY);
memDC.DeleteDC();
bitmap.DeleteObject();


打印预览的时候如下图:


而如果把pDC->SetMapMode(2); 和 memDC.SetMapMode(2); 都变1 模式的时候,是正常的,如下图



打印预览的时候正常显示.

难道打印预览不能用 pDC->BitBlt 这个功能吗?

急,,,先谢谢了!!!!
...全文
326 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
schlafenhamster 2016-12-09
  • 打赏
  • 举报
回复
注意 rc.DeflateRect(100,100); 100 是 pixel (DP)
schlafenhamster 2016-12-09
  • 打赏
  • 举报
回复
如: void CLoMetricDlg::Draw(CDC& dc) {// SCROLLINFO scrollinfo; GetScrollInfo(SB_VERT,&scrollinfo,SIF_ALL); int nPos=SCROLL_LINE*scrollinfo.nPos; // int idc=dc.SaveDC(); CRect rc; GetClientRect(&rc); // afxDump << rc << "\n";// (L 0, T 0, R 696, B 450) rc.DeflateRect(100,100); // afxDump << rc << "\n";// (L 100, T 100, R 596, B 350) dc.SetMapMode(MM_LOMETRIC); // CPoint pt(0,nPos); dc.DPtoLP(&pt); // afxDump << pt.y << "\n";// -71.... // dc.DPtoLP(rc); // afxDump << rc << "\n";// (L 353, T -353, R 2103, B -1235) dc.Rectangle(rc.left,rc.top-pt.y,rc.right,rc.bottom-pt.y); // dc.RestoreDC(idc); }
大漠飞狐 2016-12-09
  • 打赏
  • 举报
回复
没有点,如何用这两个
大漠飞狐 2016-12-06
  • 打赏
  • 举报
回复
引用 7 楼 schlafenhamster 的回复:
请 考虑 pDC->DPtoLP(p, 2);
请问这个函数要转换哪个坐标呢?我没有鼠标点击
schlafenhamster 2016-12-06
  • 打赏
  • 举报
回复
CDC::LPtoDP Converts logical units into device units. The function maps the coordinates of each point, or dimensions of a size, from GDI’s logical coordinate system into a device coordinate system. The conversion depends on the current mapping mode and the settings of the origins and extents of the device’s window and viewport. CDC::DPtoLP Converts device units into logical units. The function maps the coordinates of each point, or dimension of a size, from the device coordinate system into GDI’s logical coordinate system. The conversion depends on the current mapping mode and the settings of the origins and extents for the device’s window and viewport
schlafenhamster 2016-12-05
  • 打赏
  • 举报
回复
请 考虑 pDC->DPtoLP(p, 2);
阿源是少年 2016-12-05
  • 打赏
  • 举报
回复
兄弟,你需要搞清楚映射模式是干什么的,窗口坐标和视口坐标是如何映射的,以及各种映射模式的单位换算是什么,你这个问题就明白了,你这个问题完全是由于没搞清除映射模式导致的,跟BitBlt没有关系
大漠飞狐 2016-12-05
  • 打赏
  • 举报
回复
这例子太复杂,看得头晕,,不知道能不能用一句话说明
schlafenhamster 2016-12-04
  • 打赏
  • 举报
回复
“MM_LOENGLISH模式下使用双缓冲绘制窗口 ” http://download.csdn.net/detail/schlafenhamster/9427265 本程序演示如何在MM_LOENGLISH模式下用双缓冲绘制窗口。重点在 MM_TEXT 和 MM_LOENGLISH 模式时 BitBlt 的调用。“”
大漠飞狐 2016-12-04
  • 打赏
  • 举报
回复
文字输出??
schlafenhamster 2016-12-04
  • 打赏
  • 举报
回复

// Decode world transformation and mapping mode
//The following formula shows the math involved 
//in converting a point from page space to device space.

//Dx = ((Lx - WOx) * VEx / WEx) + VOx 
 
//The following variables are involved.
//Dx     x value in device units 
//Lx     x value in logical units (also known as page space units) 
//WOx    window x origin 
//VOx    viewport x origin 
//WEx    window x-extent 
//VEx    viewport x-extent 
void CLoEnglishView::DecodeTransform(CDC* pDC)
{
	POINT windoworg;   GetWindowOrgEx(pDC->m_hDC, &windoworg);
	SIZE  windowext;   GetWindowExtEx(pDC->m_hDC, &windowext);

	POINT viewportorg; GetViewportOrgEx(pDC->m_hDC, &viewportorg);
	SIZE  viewportext; GetViewportExtEx(pDC->m_hDC, &viewportext);

	TCHAR formulax[128];
	TCHAR formulay[128];

	wsprintf(formulax, "Dx = (Lx-%d)*(%d/%d) + %d", windoworg.x, viewportext.cx, windowext.cx, viewportorg.x);
	wsprintf(formulay, "Dy = (Ly-%d)*(%d/%d) + %d", windoworg.y, viewportext.cy, windowext.cy, viewportorg.y);

	POINT p[2] = { 10, 10, 10, 35 };
	pDC->DPtoLP(p, 2);

	pDC->SetBkMode(TRANSPARENT);
	pDC->TextOut(p[0].x, p[0].y, formulax, _tcslen(formulax));
	pDC->TextOut(p[1].x, p[1].y, formulay, _tcslen(formulay));
//
//	CRect rc(10,60,200,76);// dp
//	pDC->DPtoLP(rc);
//	pDC->DrawText("DrawText OK !",13,&rc,DT_TOP|DT_LEFT);
}
schlafenhamster 2016-12-04
  • 打赏
  • 举报
回复
/* Mapping Modes */ #define MM_TEXT 1 #define MM_LOMETRIC 2 #define MM_HIMETRIC 3 #define MM_LOENGLISH 4 #define MM_HIENGLISH 5 #define MM_TWIPS 6 #define MM_ISOTROPIC 7 #define MM_ANISOTROPIC 8

19,469

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧