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.