QT generates bitmaps based on Chinese characters, which can be called consecutively, resulting in a bitmap that has no clutter.

Source: Internet
Author: User

void MainWindow::d rawtext (int font_size, QString str, int n)
{
Qpainter p;
Qsize size (460, font_size); Specifies the image size;
qimage* image = new Qimage (size, qimage::format_argb32); Constructs a qimage in ARGB32 format,
Image->fill (Qrgba (0,0,0,0));

P.begin (image);
Qpen pen = P.pen ();
Pen.setcolor (qt::red);
Qfont font;
Font.setfamily (("SimSun"));
Font.setpixelsize (64);//Change font size

P.setpen (pen);
P.setfont (font);
P.setbackgroundmode (Qt::transparentmode);//qt::opaquemode, Transparentmode
P.setcompositionmode (Qpainter::compositionmode_destinationover);
P.drawtext (Image->rect (), Qt::aligncenter, Qobject::tr (str.tostdstring (). C_STR ())); Qt::alignleft Qt::alignright

if (1 = = N)
{
Image->save ("1.bmp");
}
Else
{
Image->save ("2.bmp");
}

P.end ();

}

QT generates bitmaps based on Chinese characters, which can be called consecutively, resulting in a bitmap that has no clutter.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.