|
楼主 |
发表于 2014-8-6 22:26:30
|
显示全部楼层
解决了,方案如下:
//标注的图标;
Style pin_System;
pin_System.getOrCreate<IconSymbol>()->url()->setLiteral("data\\placemark64.png");
//标注文字的样式;
pin_System.getOrCreate<TextSymbol>()->alignment() = TextSymbol::ALIGN_CENTER_CENTER;
pin_System.getOrCreate<TextSymbol>()->fill()->color() = Color::Yellow;
pin_System.getOrCreate<TextSymbol>()->encoding() = osgEarth::Symbology::TextSymbol::ENCODING_UTF8;
pin_System.getOrCreate<TextSymbol>()->font()="C:/WINDOWS/Fonts/STSONG.ttf";
char wsrc[512];
sprintf(wsrc, (const char *)ui.image_TxtName->text().toLocal8Bit().data());
string strUtf8;
gb2312ToUtf8(string(wsrc), strUtf8);
定义的几个函数:
void AddMarkAndPicture::gb2312ToUnicode(const string& src, wstring& result)
{
int n = MultiByteToWideChar( CP_ACP, 0, src.c_str(), -1, NULL, 0 );
result.resize(n);
::MultiByteToWideChar( CP_ACP, 0, src.c_str(), -1, (LPWSTR)result.c_str(), result.length());
}
void AddMarkAndPicture::gb2312ToUtf8(const string& src, string& result)
{
wstring strWideChar;
gb2312ToUnicode(src, strWideChar);
unicodeToUTF8(strWideChar, result);
}
|
|