使用Windows平台下的OpenSource版,4.3,编译器使用MingGW 3.4.3
我的代码如下
- #include <iostream>
- #include <QtGui\QImage>
- #include <QtCore\QString>
- using namespace std;
- int main( int argc, char* argv[] )
- {
- cout<<"Welcome";
- QString oldfilename = "test.jpg";
- QString newfilename = "test.png";
- //char* oldformat = "BMP";
- //char* newformat = "PNG";
- QImage image( oldfilename );
- if ( image.isNull())
- {
- cout<<"Image is null";
- return 1;
- }
- bool bSuc = image.save( newfilename );
- if ( bSuc )
- {
- cout<<"Save successful";
- }
- else
- {
- cout<<"Save failed";
- }
- return 0;
- }
如果是bmp就没问题,jpg就不行。不知为什么。如果是bmp,就可以顺利打开,存成png
[ 此贴被blackdire在2007-06-24 22:36重新编辑 ]