• 8589阅读
  • 4回复

是否用QImage::save(XXX)就可以保存图像,如何操作 [复制链接]

上一主题 下一主题
离线yangfanxing
 
只看楼主 倒序阅读 楼主  发表于: 2009-12-26
  1. QImage _oImageT;_oImageT.load("./hello.jpg"); //1
  2. _oImageT.save("Go.BMP", "BMP"); //2+写法???


1、载入图像,是可以显示的;
2、保存图像失败?
PHPWind好恶心。。。不想看这种界面。。。
离线benbenmajia

只看该作者 1楼 发表于: 2009-12-26
bool QImage::save ( const QString & fileName, const char * format, int quality = -1 ) const
Saves the image to the file with the given fileName, using the given image file format and quality factor.

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.

See also Reading and Writing Image Files.

bool QImage::save ( QIODevice * device, const char * format, int quality = -1 ) const
This is an overloaded member function, provided for convenience.

This function writes a QImage to the given device.

This can, for example, be used to save an image directly into a QByteArray:

            QImage image;
            QByteArray ba;
            QBuffer buffer(&ba);
            buffer.open(QIODevice::WriteOnly);
            image.save(&buffer, "PNG"); // writes image into ba in PNG format
安然.....
离线benbenmajia

只看该作者 2楼 发表于: 2009-12-26
你的QT是什么版本?
安然.....
离线benbenmajia

只看该作者 3楼 发表于: 2009-12-26
#include <QApplication>
#include <QImage>
#include <QWidget>
//
int main(int argc, char ** argv)
{
    QApplication app( argc, argv );
    QWidget win;
    QImage *image = new QImage();
    image->load("/kaiye.jpg");
    image->save("/1.jpg","jpg",1);
    
    
    win.show();
    //app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
    return app.exec();
}
安然.....
离线benbenmajia

只看该作者 4楼 发表于: 2009-12-26
没有问题,保存成功的
安然.....
快速回复
限100 字节
 
上一个 下一个