Results 1 to 5 of 5

Thread: Can't save image by QImage(save function always return 1)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: Can't save image by QImage(save function always return 1)

    Easy. Backslashes need to be escaped in C++: "C:\lena2.jpg" -> "C:\\lena2.jpg".

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Can't save image by QImage(save function always return 1)

    ... or use forward slashes for file paths everywhere in your code, avoid the missing backslash pain, and increase portability (although not with explicit drive letter references). Also, on some versions of Windows, and in many corporate environments, writing the the root of the C: drive is forbidden for non-privileged users.

  3. #3
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't save image by QImage(save function always return 1)

    Thank you very much, I solve my problem.
    But I still have other question, how could I change
    the format of the picture by Qt?I would like to
    read the other format of the QImage support,
    but some of them are hard to find, so I want to transfer
    them to the format I lack and try to do some pixel manipulation
    about them.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Can't save image by QImage(save function always return 1)

    I'll answer the obvious question. The remaining statements make little sense.

    how could I change the format of the picture by Qt?
    Load an image in one format using QImage::load() or QImage::loadFromData() and write the image to file in another format using QImage::save(). The supported formats are in the docs for QImage and QImageReader.

Similar Threads

  1. save Qimage in a file
    By OverTheOCean in forum Qt Programming
    Replies: 7
    Last Post: 20th March 2011, 23:42
  2. QImage->save(); returns 0
    By ramzes13 in forum Newbie
    Replies: 2
    Last Post: 22nd September 2010, 14:49
  3. Can't save QImage
    By hvengel in forum Qt Programming
    Replies: 6
    Last Post: 14th June 2008, 21:07
  4. QImage : trouble with save() method
    By krivenok in forum Qt Programming
    Replies: 12
    Last Post: 3rd May 2006, 20:55
  5. Replies: 3
    Last Post: 15th March 2006, 11:44

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.