读书人

textout函数在图像上英汉文字母是乱码

发布时间: 2012-01-16 23:36:51 作者: rapoo

textout函数在图像上英汉文字母是乱码,100分求救,十万火急
szNewText=“abcds请您帮忙”;

LONG cx, cy;
HRESULT hr;

// Read the default video size
hr = pWC-> GetNativeVideoSize(&cx, &cy, NULL, NULL);
if (FAILED(hr))
return hr;

g_NativeHeight=cy;
g_NativeWidth=cx;


HDC hdc = GetDC(hwndApp);
HDC hdcBmp = CreateCompatibleDC(hdc);


HFONT hOldFont = (HFONT) SelectObject(hdcBmp, g_hFont);


int nLength, nTextBmpWidth, nTextBmpHeight;
SIZE sz={0};
nLength = (int) _tcslen(szNewText);
GetTextExtentPoint32(hdcBmp, szNewText, nLength, &sz);
nTextBmpHeight = sz.cy;
nTextBmpWidth = sz.cx;

g_TextHeight=sz.cy;
g_TextWidth=sz.cx;


HBITMAP hbm = CreateCompatibleBitmap(hdc, nTextBmpWidth, nTextBmpHeight);
ReleaseDC(hwndApp, hdc);


BITMAP bm;
HBITMAP hbmOld;
GetObject(hbm, sizeof(bm), &bm);
hbmOld = (HBITMAP)SelectObject(hdcBmp, hbm);


RECT rcText;
SetRect(&rcText, 0, 0, nTextBmpWidth, nTextBmpHeight);
SetBkColor(hdcBmp, RGB(255, 255, 255)); // Pure white background
SetTextColor(hdcBmp, g_rgbColors); // Write text with requested color

TextOut(hdcBmp, 0, 0, szNewText, nLength);



这样使用textout函数在图像上打字后在英文字母后是乱码,如果都是英文就不会乱码。这是啥原因啊,请您帮忙,



[解决办法]
用unicode
[解决办法]
有工程没大不?发给我,我帮你搞
lixb@xinli.com.cn

[解决办法]
szNewText 什么类型?
[解决办法]
你使用中文创天VC++编译器,它认中文输入

读书人网 >VC/MFC

热点推荐