Results 1 to 1 of 1

Thread: [SOLVED] QImage problem - adding/reading path of image with key/text [SOLVED]

  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Question [SOLVED] QImage problem - adding/reading path of image with key/text [SOLVED]

    Hello, I've written following code:
    Qt Code:
    1. bool CMerchandizeBrowser::embeddedPicPath(QImage image, QString strFilename)
    2. {
    3. QImageWriter picImageWriter; // image key writer
    4.  
    5. picImageWriter.setFormat(strSupportedFormat); // sets supported format
    6. if (picImageWriter.supportsOption(QImageIOHandler::Description))
    7. {
    8. qDebug() << strSupportedFormat << " supports embedded text.";
    9. if (image.text(strKeyImagePathName).isEmpty())
    10. {
    11. // pic path has not yet been saved
    12. image.setText(strKeyImagePathName, strFilename); // sets embedded text
    13. return image.save(strFilename, strSupportedFormat); // saves pic with embedded text
    14. } else {
    15. return false; // path already embedded, abort operation
    16. }
    17. } else {
    18. qDebug() << strSupportedFormat << " does not support embedded text.";
    19. return false; // operation failure
    20. }
    21. return false; // operation failure
    22. }
    To copy to clipboard, switch view to plain text mode 
    which is responsible to embedd a QImage path into image, but
    Qt Code:
    1. return image.save(strFilename, strSupportedFormat);
    To copy to clipboard, switch view to plain text mode 
    returns false. Does anyone has idea why?

    Now I thought the chenged picture cannot be written into same filename and I've changed code to:
    Qt Code:
    1. bool CMerchandizeBrowser::embeddedPicPath(QImage image, QString strFilename)
    2. {
    3. QImageWriter picImageWriter; // image key writer
    4.  
    5. picImageWriter.setFormat(strSupportedFormat); // sets supported format
    6. if (picImageWriter.supportsOption(QImageIOHandler::Description))
    7. {
    8. qDebug() << strSupportedFormat << " supports embedded text.";
    9. if (image.text(strKeyImagePathName).isEmpty())
    10. {
    11. // pic path has not yet been saved
    12. image.setText(strKeyImagePathName, strFilename); // sets embedded text
    13. strFilename.insert(strFilename.indexOf(strNameExtDelimiter), strFilenameEmbeddedExtendtor);
    14. qDebug() << "strFilename: " << strFilename; // debug
    15. return image.save(strFilename, strSupportedFormat); // saves pic with embedded text
    16. } else {
    17. return false; // path already embedded, abort operation
    18. }
    19. } else {
    20. qDebug() << strSupportedFormat << " does not support embedded text.";
    21. return false; // operation failure
    22. }
    23. //return true; // operation sucess
    24. }
    To copy to clipboard, switch view to plain text mode 
    It works now, thank you all anyway!
    Last edited by MarkoSan; 14th December 2007 at 06:41.
    Qt 5.3 Opensource & Creator 3.1.2

Similar Threads

  1. Replies: 12
    Last Post: 7th September 2011, 16:37
  2. QImage on windows
    By J-jayz-Z in forum Installation and Deployment
    Replies: 3
    Last Post: 26th September 2007, 21:27
  3. RGBComponents / QImage Conversion problem
    By sincnarf in forum Qt Programming
    Replies: 2
    Last Post: 30th July 2007, 23:41
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.