在Qt中保存QImage(Save a QImage in Qt)
是否可以导出Qt创建者生成的图像? qimage是Qt中内置的数据类型。 我们使用setpixel()函数修改它。 我想保存该图像以供进一步使用。
Is it possible to export images generated in Qt creator? The qimage which is a built in data type in Qt. We modify it using setpixel() function. I want to save that image for further use.
原文:https://stackoverflow.com/questions/27958716
2019-06-06 11:06
满意答案
您可以使用
bool QImage::save ( const QString & fileName, const char * format = 0, int quality = -1 ) const
保存你的QImage
使用给定的图像文件格式和品质因数将图像保存到具有给定fileName的文件。 如果format为0,QImage将尝试通过查看fileName的后缀来猜测格式。
品质因数必须在0到100或-1的范围内。 指定0以获取小型压缩文件,指定100表示大型未压缩文件,使用-1(默认值)使用默认设置。
如果图像成功保存,则返回true; 否则返回false。
You can use
bool QImage::save ( const QString & fileName, const char * format = 0, int quality = -1 ) const
To save your QImage
Saves the image to the file with the given fileName, using the given image file format and quality factor. If format is 0, QImage will attempt to guess the format by looking at fileName's suffix.
The quality factor must be in the range 0 to 100 or -1. Specify 0 to obtain small compressed files, 100 for large uncompressed files, and -1 (the default) to use the default settings.
Returns true if the image was successfully saved; otherwise returns false.
2015-01-15
相关问答
您可以使用 bool QImage::save ( const QString &