由于某些原因,DrawString的输出变得非常模糊。我正在寻找与Windows菜单相同的清晰度,请参阅附图作为参考。
Gdiplus::Graphics graphics(m_DeviceContextHandle);
Gdiplus::FontFamily nameFontFamily(L"Segoe UI");
Gdiplus::Font font(&nameFontFamily, 9);
Gdiplus::SolidBrush solidbrush(Gdiplus::Color(255, 0, 0, 0));
graphics.SetCompositingQuality(Gdiplus::CompositingQuality::CompositingQualityAssumeLinear);
graphics.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeHighQuality);
graphics.SetPixelOffsetMode(Gdiplus::PixelOffsetMode::PixelOffsetModeHighQuality);
graphics.SetTextRenderingHint(Gdiplus::TextRenderingHint::TextRenderingHintClearTypeGridFit);
graphics.DrawString(L"File Edit Format View Help", -1, &font, Gdiplus::PointF(10, 10), &solidbrush);
任何想法如何使文本更清晰?
修改
这是我绘制到位图而不是窗口时的结果。 第一个文本来自位图输出,最后一个文本来自我绘制到窗口时。
代码:
// Draw to bitmap.
Gdiplus::Bitmap b(100, 100);
Gdiplus::Graphics *g = Gdiplus::Graphics::FromImage(&b);
// Draw text.
// ...
// Save bitmap.
CLSID pngClsid;
CLSIDFromString(L"{557cf406-1a04-11d3-9a73-0000f81ef32e}", &pngClsid);
b.Save(L"C:\\my_path_here\\out.png", &pngClsid, NULL);
有什么想法吗?我的窗口设置不正确?