Results 1 to 10 of 10

Thread: qImage saving to jpg problem

  1. #1
    Join Date
    Aug 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default qImage saving to jpg problem

    Hello again.
    I have problems with saving qImage to jpg.
    On the very begining i was trying to use QPixmap::save() like this:
    Qt Code:
    1. QString saveFile=QFileDialog::getSaveFileName(this,tr("save"),QDir::homePath());
    2. if(!saveFile.isEmpty())
    3. if(!tlo->save(saveFile,".JPG",100));
    To copy to clipboard, switch view to plain text mode 
    but it didn't work(no errors, just was not saving file), so i have tried qimagewriter and... on the one computer it's working on the other not... the code is:
    Qt Code:
    1. QString saveFile=QFileDialog::getSaveFileName(this,tr("save"),QDir::homePath());
    2. if(!saveFile.isEmpty()){
    3. QImageWriter writer(saveFile);
    4. writer.write(*tlo);
    5. if(writer.canWrite())
    6. qDebug("i can write");
    7. else
    8. qDebug("i can't write");
    9. qDebug()<< writer.errorString();
    10. }
    To copy to clipboard, switch view to plain text mode 

    it shows me "i can write" co there is no problems with opening file to write and no problems with qimage... the error line is "unknown problem"
    any ideas about the solution? any ideas why save() didn't work? i really will appreciate help.
    thank

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: qImage saving to jpg problem

    Make sure you have the jpeg plugin on the right place that your app can find it.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qImage saving to jpg problem

    The format name is "JPG" or "JPEG" and not ".JPG".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Aug 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qImage saving to jpg problem

    Quote Originally Posted by wysota View Post
    The format name is "JPG" or "JPEG" and not ".JPG".
    Thanks, fixed, but save() still doesn't work. It gives me true as return, but dosn't save the file.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qImage saving to jpg problem

    Check the path, maybe it saves the image in a different directory than you expect.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Aug 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qImage saving to jpg problem

    That would be the idea, but it takes path from QFileDialog. Anyway, can't find such file in any directory. Doesn't matter with save. Just why on one computer i have problems with QImageWriter, on the other not. Same Qt 4.6.0 from same instalation files, different OS - winxp(works) win764b(doesn't work).

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qImage saving to jpg problem

    Quote Originally Posted by sqarpi View Post
    That would be the idea, but it takes path from QFileDialog.
    And that makes it impossible to dump it to the console?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Aug 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qImage saving to jpg problem

    Qt Code:
    1. qDebug(saveFile.toLatin1)
    To copy to clipboard, switch view to plain text mode 
    shows correct path.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qImage saving to jpg problem

    So check if the location is writable to the current user, etc. Also dump QImageWriter::supportedImageFormats() to the console.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Aug 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qImage saving to jpg problem

    That's it. Opening program as an administrator helped, but funny, i didn't have such problems with writing a text to file.
    Thanks mates for the brainstorm.

Similar Threads

  1. Problem saving txtfile contents to database
    By cutie.monkey in forum Qt Programming
    Replies: 0
    Last Post: 6th January 2010, 07:11
  2. Problem saving JPG image
    By avis_phoenix in forum Newbie
    Replies: 1
    Last Post: 31st July 2009, 15:38
  3. Problem saving a plot
    By kalos80 in forum Qwt
    Replies: 2
    Last Post: 10th July 2008, 08:31
  4. Saving a QPixmap Object problem
    By StrikerX in forum General Programming
    Replies: 4
    Last Post: 15th November 2007, 02:19
  5. problem with saving QCstrings
    By nass in forum Qt Programming
    Replies: 3
    Last Post: 5th October 2006, 15:12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.