PDA

View Full Version : Problem loading QPixmap on Qt 4.2 in Symbian s60



Tito
9th May 2010, 01:36
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):

QString filename(":/data/test.jpg");
QFileInfo fileInfo(filename);
if (!(fileInfo.exists() && fileInfo.isFile() && fileInfo.isReadable()))
Q_ASSERT(0);
QFile file(filename);
if (!file.open(QIODevice::ReadOnly))
{
QString err = file.errorString();
Q_ASSERT(0);
}
else
{
file.close();
}
QPixmap picture(filename);
if (picture.isNull())
Q_ASSERT(0);

Lykurg
9th May 2010, 10:40
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...

Tito
9th May 2010, 12:01
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.html#reading-and-writing-image-files.

Or do I need to install an image plugin even for the base supported types?

Lykurg
9th May 2010, 15:00
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.html#reading-and-writing-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.

aamer4yu
9th May 2010, 15:35
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..

Tito
10th May 2010, 03:44
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

aamer4yu
10th May 2010, 05:30
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

Tito
10th May 2010, 22:25
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?

aamer4yu
11th May 2010, 05:56
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.

Tito
11th May 2010, 13:30
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