#include <QtGui/QApplication>#include "mainwindow.h"#include <QImageWriter>#include <QDebug>int main(int argc, char *argv[]){ QApplication a(argc, argv); //QImage img("1.jpg"); QImageWriter writer("2.jpg"); qDebug() << "1: " << writer.format(); //writer.write(img); return a.exec();}
C++ (Qt)QImageWriter::QImageWriter(const QString &fileName, const QByteArray &format) : d(new QImageWriterPrivate(this)){ QFile *file = new QFile(fileName); d->device = file; d->deleteDevice = true; d->format = format;} /*! Sets the format QImageWriter will use when writing images, to \a format. \a format is a case insensitive text string. Example: \snippet doc/src/snippets/code/src_gui_image_qimagewriter.cpp 0 You can call supportedImageFormats() for the full list of formats QImageWriter supports. \sa format()*/void QImageWriter::setFormat(const QByteArray &format){ d->format = format;} /*! Returns the format QImageWriter uses for writing images. \sa setFormat()*/QByteArray QImageWriter::format() const{ return d->format;}