常见问题 TBarCode DLL / TBarCode Library
如何生成带抗锯齿字体渲染的位图输出?
如何生成带抗锯齿字体渲染的位图输出?
调整正确的 DC
使用以下屏幕 DC 来创建带抗锯齿选项的字体渲染(按屏幕调整):
HDC dc = CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL);
eCode = BCSaveImageEx(m_pbarCode, dc, file, imageType, 100, widthPx, heightPx, dpi, dpi );
if (dc)
DeleteDC(dc);
调整正确的字体(LOGFONT)
使用 Windows 标准字体对话框,或使用以下函数从 Windows GDI 获取一个预初始化的 LOGFONT 结构:
HFONT hSystemVariableFont = (HFONT ) GetStockObject( ANSI_VAR_FONT ); LOGFONT lfSystemVariableFont; GetObject ( hSystemVariableFont, sizeof(LOGFONT), &lfSystemVariableFont ); // Make sure that the following flags are set in the LOGFONT structure passed to BCSetLogFont(): lfOutPrecision (e.g. set to 3) lfClipPrecision (e.g. set to 2) lfQuality (e.g. set to 1) lfWeight (e.g. set to 400) lfFaceName should be set to a True Type font (e.g. “Arial”) // Calculate the font height as follows: lfHeight = = -MulDiv( 10 /*PointSize*/, GetDeviceCaps(hDC, LOGPIXELSY), 72);