Results 1 to 10 of 10

Thread: Loading Image in DocumentGalleryModel takes extremely long tine

  1. #1
    Join Date
    May 2010
    Posts
    61
    Thanks
    2
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Loading Image in DocumentGalleryModel takes extremely long tine

    Hi Guys,

    I am trying to use the QML DocumentGalleryModel with the following code (on my Symbian N8 device):
    Qt Code:
    1. import Qt 4.7
    2. import QtMobility.gallery 1.1
    3.  
    4. Rectangle {
    5. width: 600
    6. height: 360
    7. color: "lightblue"
    8.  
    9. GridView {
    10. id: gridView
    11. anchors.fill: parent
    12. cellWidth: 128
    13. cellHeight: 128
    14.  
    15. model: DocumentGalleryModel {
    16. rootType: DocumentGallery.Image
    17. properties: [ "url" ]
    18. }
    19.  
    20. delegate:
    21. Item {
    22. Image {
    23. id: imageBusy
    24. source: "busy.png"
    25. width: 110
    26. height: 110
    27. sourceSize.width: 110
    28. sourceSize.height: 110
    29. visible: imageDelegate.status != Image.Ready
    30. }
    31. Image {
    32. id: imageDelegate
    33. asynchronous: true
    34. source: url
    35. smooth: true
    36. width: 110
    37. height: 110
    38. fillMode: Image.PreserveAspectFit
    39. sourceSize.width: 110
    40. sourceSize.height: 110
    41. onStatusChanged: {
    42. console.log("Status is: " + status);
    43. }
    44. }
    45. }
    46. }
    47. }
    To copy to clipboard, switch view to plain text mode 

    The problem is that displaying the images takes super long time (for just 20 images it takes around 10 seconds).

    Any ideas on how can I improve this time?

    I also know that drawing the image is problematic, hence retrieving the data from the model goes straight forward. It's also true that the images have a big resolution (aprox. 4000 x 2000).

    Any leads are highly appreciated.

    Thanks in advance and regards,
    Wladek
    One second is long, everything longer than two seconds is definitely too long.

  2. #2
    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: Loading Image in DocumentGalleryModel takes extremely long tine

    If you use really large images then they have to be scaled now and then and it takes time. If you know you need the image in a particular resolution, it is best to scale the image down before using it. Otherwise you're just wasting cpu cycles as your device can't display such large images anyway.
    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.


  3. #3
    Join Date
    May 2010
    Posts
    61
    Thanks
    2
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Loading Image in DocumentGalleryModel takes extremely long tine

    Hi wysota,

    I definitely do not want to use them in such a big resolution.
    So I should use the QML Item's scale property?

    Something like:
    Qt Code:
    1. Image {
    2. id: imageDelegate
    3. asynchronous: true
    4. source: url
    5. smooth: true
    6. width: 110
    7. height: 110
    8. fillMode: Image.PreserveAspectFit
    9. sourceSize.width: 110
    10. sourceSize.height: 110
    11. scale: 0.3 //for example?
    To copy to clipboard, switch view to plain text mode 

    Wladek.
    One second is long, everything longer than two seconds is definitely too long.

  4. #4
    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: Loading Image in DocumentGalleryModel takes extremely long tine

    You can certainly try that but in general I would scale them down before going into QML layer.
    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.


  5. #5
    Join Date
    May 2010
    Posts
    61
    Thanks
    2
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Loading Image in DocumentGalleryModel takes extremely long tine

    And how should I try to achieve such a think?
    One second is long, everything longer than two seconds is definitely too long.

  6. #6
    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: Loading Image in DocumentGalleryModel takes extremely long tine

    You can use Qt/C++ and then expose the images to QML.
    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.


  7. #7
    Join Date
    May 2010
    Posts
    61
    Thanks
    2
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Loading Image in DocumentGalleryModel takes extremely long tine

    So you think I should implement my own model?
    But in that way I could not benefit from all the advantages the DocumentGalleryModel has to offer, would I?

    Thanks,
    Wladek
    One second is long, everything longer than two seconds is definitely too long.

  8. #8
    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: Loading Image in DocumentGalleryModel takes extremely long tine

    Quote Originally Posted by wladek View Post
    So you think I should implement my own model?
    I think you should use smaller images. The way you do it is a secondary issue. If an image is big and you want to fit it into a small screen it has to be scaled down and this takes time. You can't eat a cake and have the cake.
    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.


  9. #9
    Join Date
    May 2010
    Posts
    61
    Thanks
    2
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Loading Image in DocumentGalleryModel takes extremely long tine

    So what do you suggest in order to get the images smaller?

    Wladek
    One second is long, everything longer than two seconds is definitely too long.

  10. #10
    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: Loading Image in DocumentGalleryModel takes extremely long tine

    Scale them down before you display them and store the thumbnails for future use. You can run a native function after you fetch the image from the model and before you display it. You can run the function in a worker thread to avoid freezing the UI.
    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.


Similar Threads

  1. QTextEdit loading takes long time
    By sreedhar in forum Qt Programming
    Replies: 12
    Last Post: 21st March 2011, 10:29
  2. Problem: the Application Takes very long time to build
    By Ma7moud El-Naggar in forum Qt Programming
    Replies: 5
    Last Post: 20th November 2010, 06:26
  3. Replies: 2
    Last Post: 5th October 2010, 08:20
  4. [QTableWidget] clearing a big table takes so long!
    By punkypogo in forum Qt Programming
    Replies: 4
    Last Post: 5th August 2010, 13:52
  5. QImage::scaled takes long time
    By nrabara in forum Qt Programming
    Replies: 0
    Last Post: 15th December 2009, 12:19

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.