Results 1 to 10 of 10

Thread: Problem loading QPixmap on Qt 4.2 in Symbian s60

  1. #1
    Join Date
    May 2010
    Posts
    19
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Problem loading QPixmap on Qt 4.2 in Symbian s60

    I'm trying to load a jpg from the resources but it fails every time. I'm checking that the file exists and can be opened, but it will not load into a pixmap. Any suggestions?

    Here's the code snippet (not very subtle but each assert is a failure - it fails on line 17):
    Qt Code:
    1. QString filename(":/data/test.jpg");
    2. QFileInfo fileInfo(filename);
    3. if (!(fileInfo.exists() && fileInfo.isFile() && fileInfo.isReadable()))
    4. Q_ASSERT(0);
    5. QFile file(filename);
    6. if (!file.open(QIODevice::ReadOnly))
    7. {
    8. QString err = file.errorString();
    9. Q_ASSERT(0);
    10. }
    11. else
    12. {
    13. file.close();
    14. }
    15. QPixmap picture(filename);
    16. if (picture.isNull())
    17. Q_ASSERT(0);
    To copy to clipboard, switch view to plain text mode 

  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: Problem loading QPixmap on Qt 4.2 in Symbian s60

    Hi,

    I never used jpeg on s60, so I am not sure if it is supported right out of the box. Do you have checked if the jpeg image plugin is "installed"? Try a png (which is supported) if then everything is working, you don't have the jpeg plugin...

  3. #3
    Join Date
    May 2010
    Posts
    19
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: Problem loading QPixmap on Qt 4.2 in Symbian s60

    I checked with a png file and I have exactly the same problem. As for the jpg format, the documentation says that jpgs are supported as default on 4.6.2 http://doc.qt.nokia.com/4.6/qpixmap....ng-image-files.

    Or do I need to install an image plugin even for the base supported types?
    Last edited by Tito; 9th May 2010 at 12:16.

  4. #4
    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: Problem loading QPixmap on Qt 4.2 in Symbian s60

    Quote Originally Posted by Tito View Post
    I checked with a png file and I have exactly the same problem. As for the jpg format, the documentation says that jpgs are supported as default on 4.6.2 http://doc.qt.nokia.com/4.6/qpixmap....ng-image-files.

    Or do I need to install an image plugin even for the base supported types?
    No, I just was unsure if it works out of the box. Hm, but in your code I see no error and I don't have any idea what the error could be. I am out. sorry.

  5. The following user says thank you to Lykurg for this useful post:

    Tito (10th May 2010)

  6. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem loading QPixmap on Qt 4.2 in Symbian s60

    Whats the size of the file ?
    Try this - reduce the size of jpeg to 1024x768 and see if it loads.

    I also had similar problem loading jpg files with higher resolutions. But when I changed resolution to 1024x768, it loaded without any change in code

    FYI : I used Nokia Qt SDK,,,the latest one..

  7. #6
    Join Date
    May 2010
    Posts
    19
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: Problem loading QPixmap on Qt 4.2 in Symbian s60

    ok.. I used a smaller png and that works, but I still can't get the jpg to load even with a smaller size... so maybe the QImageReader::supportedImageFormats() is not related to the QPixmap as the documentation says..

    Which may mean I need a plugin.. so I'm a bit stymied now.

    (I tried adding the qjpeg plugin but the plugin file said it just a stub.... )

    oh... btw... it's 4.6.2 I'm using.. the 4.2 was a typo

  8. #7
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem loading QPixmap on Qt 4.2 in Symbian s60

    what size were you using for the jpeg ?
    try with the smallest size(say 64x64 ) you can so that you can be sure its not a matter of plugin missing or something.
    Also am not sure where the plugin files stay in mobile... usually on desktop, you need 'imageformats' folder in the app directory for the jpeg to run.
    Not sure how it is on S60

  9. #8
    Join Date
    May 2010
    Posts
    19
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: Problem loading QPixmap on Qt 4.2 in Symbian s60

    Ok.. it works with a 64x64 image.. but not with a 260x192 or a 2592x1944 image.. which is definitely a problem.. as I want to display an image from the camera..

    one step forward, two steps back..

    is there any way to display a large image with this?

  10. #9
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem loading QPixmap on Qt 4.2 in Symbian s60

    Try scaling the image down to 1024x768.
    I dont think any mobile has even that resolution. Better scale the camera image to screen resolution.

    Also if you are able to find a proper solution do post it. I doubt it to being memory related issue, since mobiles have limited memory.

  11. #10
    Join Date
    May 2010
    Posts
    19
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: Problem loading QPixmap on Qt 4.2 in Symbian s60

    Very odd.. suddenly the same code is working at 1024 by 1024. However I still need it to work with an image at full camera resolution (2592x1944 ).

    You mentioned scaling the image... is there a way to load a scaled image into a QPixmap... bearing in mind that the image on the phone will be 2592x1944

Similar Threads

  1. QPixmap not loading image(from file) after deployment.
    By csmithmaui in forum Installation and Deployment
    Replies: 4
    Last Post: 23rd February 2010, 02:44
  2. image loading problem using qpixmap
    By dutt_004 in forum Qt Programming
    Replies: 4
    Last Post: 23rd February 2010, 01:18
  3. Loading a QPixmap from raw data
    By pherthyl in forum Qt Programming
    Replies: 1
    Last Post: 27th January 2008, 10:12
  4. Loading jpeg (QPixmap with Qt Jambi)
    By Mr_Blonde in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2006, 18:06
  5. Loading a custom image into a QPixmap
    By KShots in forum Qt Programming
    Replies: 12
    Last Post: 5th August 2006, 00:16

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.