先上一张效果图


这里花鸟字每一个字都是一张图片,实现过程即通过输出的文字去获取对应的图片,而后平铺绘制到一张图片上,格局可本人设置三五个一行都能够,把输出的文字合成到一张图片上,之后把图片居中显示进去就是界面上的成果


以下附上应用C++的一种实现形式,实践上只有所用语言反对图片绘制就能够移植或者自行实现

// 绘制代码void CArt::Paint(Graphics& v_graphics){        v_graphics.TranslateTransform(m_nFrameWidth / 2.0f, m_nFrameHeight / 2.0f);    if (m_pBgImage && m_vetFileList.size() < 4) v_graphics.DrawImage(m_pBgImage, Rect(-m_nBgWidth / 2.0f, -m_nBgHeight / 2.0f, m_nBgWidth + 0.0f, m_nBgHeight + 0.0f), 0, 0, m_nBgWidth, m_nBgHeight, UnitPixel);    if (m_pFontImage) v_graphics.DrawImage(m_pFontImage, Rect(-m_nFontWidth / 2.0f, -m_nFontHeight / 2.0f, m_nFontWidth + 0.0f, m_nFontHeight + 0.0f), 0, 0, m_nFontWidth, m_nFontHeight, UnitPixel);}// 生成花鸟字图片bool CArt::LoadImage(string strURI){    bool bRet = false;    int length = strURI.length();    if (length && length % 6 == 0) {        m_vetFileList.clear();        SAFE_DELETE(m_pFontImage);        for (int i = 0; i < length; i += 6) {            string str = strURI.substr(i, 6);            str += ".jpg";            m_vetFileList.emplace_back(str);        }        int size = m_vetFileList.size();        if (size > 0) {            m_nFontWidth = FONT_WIDTH * size;            m_nFontHeight = FONT_HEIGHT;            m_pFontImage = new Bitmap(m_nFontWidth, m_nFontHeight);            Graphics gs(m_pFontImage);            for (int i = 0; i < size; i++) {                string strFileName = g_strWorkDir + "/art/data/" + m_vetFileList[i];                CString strImage(strFileName.c_str());                Bitmap image(strImage);                gs.DrawImage(&image, Rect(i * FONT_WIDTH, 0, FONT_WIDTH, FONT_HEIGHT), 0, 0, FONT_WIDTH, FONT_HEIGHT, UnitPixel);            }            Update();            bRet = true;        }    }    return bRet;}// 按钮点击事件void OnBtnAdd() {    CDuiString strText = m_pEditText->GetText();    string strUtf8;    bool bRet = tools::UnicodeToUtf8(strText.GetData(), strUtf8);    if (bRet) {        string strURI = encodeURIComponent(strUtf8, false);        CArt* pArt = new CArt();        if (pArt) {            bool bRet = pArt->LoadImage(strURI);        }    }}