I am coding an image processing application. I draw a text on the displayed image by using CDC:DrawText or CDC::TextOut like below:
pDC->SetGraphicsMode(GM_ADVANCED);
pDC->SetMapMode(MM_ISOTROPIC) ;
pDC->SetViewportOrg(CPoint(100, 100));
pDC->SetWindowExt(CSize(100, 100));
pDC->SetViewportExt(CSize(100*zoomRatio, 100*zoomRatio));
XFORM xForm;
xForm.eM11 = 1;
xForm.eM12 = 0;
xForm.eM21 = 0;
xForm.eM22 = 1;
xForm.eDx = -100;
xForm.eDy = -100;
pDC->SetWorldTransform(&xForm);
CRect rtText(0, 0, 100, 100);
CString strText = _T("Test");
pDC->DrawText(strText, rtText, DT_LET | DT_TOP);
The right result is that the strText is drawn from the left-top of the rtText
the two functions, DrawText and Text out, give me the right results if the zoomRatio = 1. However when I scale the image that cause zoomRatio changed, only the function TextOut gives me the right result and the function DrawText shows a wrong result that the strText is moved to another position in rtText.
I have been trying to find a solution to use DrawText for scaling but I failed.
Anyone know about this issue, please let me know.
Thank you in advance