各位高手,还是那个关于坐标变换的比较经典的例子:
CRect rectClient;
GetClientRect(rectClient);
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetWindowExt(1000, 1000);
pDC->SetViewportExt(rectClient.right, -rectClient.bottom);
pDC->SetViewportOrg(rectClient.right / 2, rectClient.bottom / 2);
pDC->Ellipse(CRect(-500, -500, 500, 500));
整个程序的意图小弟是明白的。但是还有一点还不是很清楚:第五行的y坐标是负号(-rectClient.bottom),可是到了第六行为什么是正号(rectClient.bottom / 2)呢?请大虾们多多指教
CRect rectClient;
GetClientRect(rectClient);
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetWindowExt(1000, 1000);
pDC->SetViewportExt(rectClient.right, -rectClient.bottom);
pDC->SetViewportOrg(rectClient.right / 2, rectClient.bottom / 2);
pDC->Ellipse(CRect(-500, -500, 500, 500));
整个程序的意图小弟是明白的。但是还有一点还不是很清楚:第五行的y坐标是负号(-rectClient.bottom),可是到了第六行为什么是正号(rectClient.bottom / 2)呢?请大虾们多多指教
第六行为什么是正号(rectClient.bottom / 2):Viewport的坐标原点基于屏幕Reference:
<Windows程序设计>的第五章-GDI的映射方式
pDC->SetViewportExt(rectClient.right, -rectClient.bottom);
上句是把wnd中的y映射到viewport中的-y。
pDC->SetViewportOrg(rectClient.right / 2, rectClient.bottom / 2);
上句是指定viewport的原点从客户区的左上角(0,0)移动到客户区的中心。