如何解决MFC GDI +文本呈现问题
我当前正在使用5MP Camera,所以我将BYTE *转换为GDI +位图对象,并使用Graphics对象在图片控件上绘制(所有GDI +对象)
,我想在上面画一个字符串,当这样做时,分辨率(质量或其他)变得奇怪。这是图像。
这是原始图片
这是我的代码。它使用MFC的WM_MOUSEMOVE。当鼠标指针移到CRect(dispRC [array])上时,它将在位图对象上呈现字符串“ aa”。
当我这样做时,图像质量会降低,或者我不完全知道它会改变图像。 (您可能不会注意到,因为这些是捕获的图像,但是后一幅图像的质量会降低。)
void CSmall_StudioDlg::OnMouseMove(UINT nFlags,CPoint point)
{
CPoint insidePoint;
// MAXCAM is the number of bitmap objects.
for (int i = 0; i < MAXCAM; i++)
{
// m_pBitmap[MAXCAM] is array of BitmaP* which contains address of Gdiplus::Bitmap objects.
if (m_pBitmap[i] != NULL)
{
// m_rcdisp[MAXCAM] are CRect objects which has information of picture control.
// i.e. GetDlgitem(IDC_BIN_disP)->GetwindowRect(m_rcdisp[BINARY_VID]);
if (point.x > m_rcdisp[i].TopLeft().x && point.y > m_rcdisp[i].TopLeft().y)
{
if (point.x < m_rcdisp[i].Bottomright().x && point.y < m_rcdisp[i].Bottomright().y)
{
StringFormat SF;
insidePoint.x = point.x - m_rcdisp[i].TopLeft().x;
insidePoint.y = point.y - m_rcdisp[i].TopLeft().y;
Graphics textG(m_pBitmap[i]);
textG.SetTextRenderingHint(TextRenderingHintSingleBitPerPixel);
Gdiplus::Font F(L"Palatino Linotype Bold",10,FontStyleBold,UnitPixel);
RectF R(insidePoint.x,insidePoint.y,20,100);
SF.SetAlignment(StringalignmentCenter);
SF.SetLineAlignment(StringalignmentCenter);
SolidBrush B(Color(0,0));
textG.DrawString(_T("aa"),-1,&F,R,&SF,&B);
// m_pGraphics[MAXCAM] is made like this
// i.e.
// static cclientDC roiDc(GetDlgitem(IDC_ROI_disP));
// m_hDC[ROI_VID] = roiDc.GetSafeHdc();
// m_pGraphics[ROI_VID] = Graphics::FromHDC(m_hDC[ROI_VID]);
m_pGraphics[i]->DrawImage(m_pBitmap[i],m_vidwidth[i],m_vidheight[i]);
}
}
}
}
CDialogEx::OnMouseMove(nFlags,point);
}
希望我得到一个有用的答案。
谢谢!
解决方法
我遇到了类似的问题,并通过这样的Windows字体创建了GDI +字体来解决了这个问题:
Gdiplus::Font font(hDc,hFont);
其中hDc是DC句柄,hFont是字体句柄。
可以帮忙吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。