I am using MM_ANIOSTROPIC mode in memory device context. I create a single pixel pen but it is too thick. I than tried to set just one pixel and that one pixel is also just thick! How can I use just a single pixel pen? You can see in the attach image the text drawn is so big.
Code:#define BMP_WIDTH 400 #define BMP_HEIGHT 200If I change the call to dcMem.SetWindowExt(400, 200); than everything is drawn correctly in correct sizes. I just don't want text to scale per MM_ANISOTROPIC mode and use fixed 1 pixel ones. It works in regular dc but not so in memory dc. Any pointers please?Code:void CDrawDlg::Draw(CDC * pDC) { CBitmap bitmap; bitmap.CreateCompatibleBitmap(pDC, BMP_WIDTH, BMP_HEIGHT); CDC dcMem; dcMem.CreateCompatibleDC(pDC); CBrush brush (RGB(0,0,255)); CBitmap * pOldBitmap = dcMem.SelectObject(&bitmap); BITMAP BM; bitmap.GetBitmap(&BM); dcMem.FillRect(CRect (0, 0, BM.bmWidth, BM.bmHeight), &brush); dcMem.SetMapMode(MM_ANISOTROPIC); dcMem.SetViewportExt(BMP_WIDTH, BMP_HEIGHT); dcMem.SetWindowExt(400 * 4, 200 * 4); // select a single pixel pen CPen pen(PS_SOLID | PS_COSMETIC, 0, RGB(255,0,0)); //CPen pen; //pen.CreateStockObject(BLACK_PEN); CPen* oldPen = dcMem.SelectObject(&pen); dcMem.SetPixel(0, 100 , RGB(255, 0, 0)); // a test, even this one pixel is just too thick in the output! dcMem.TextOut(0,0, _T("(0,0)")); // draw something at the new center dcMem.TextOut(30,30, _T("(30,30)")); dcMem.MoveTo(0, 0); dcMem.LineTo(BMP_WIDTH, BMP_HEIGHT); pDC->BitBlt(50, 50, BM.bmWidth, BM.bmHeight, &dcMem, 0, 0, SRCCOPY); dcMem.SelectObject(pOldBitmap); dcMem.SelectObject(oldPen); }




Reply With Quote