Skip navigation.
Home
The QNX Community Portal

View topic - [solved] Displaying a .jpg picture in a QPixmap

[solved] Displaying a .jpg picture in a QPixmap

Isn't the name clear?

[solved] Displaying a .jpg picture in a QPixmap

Postby Noir » Tue Sep 24, 2013 12:12 pm

Hi @ all!

I want to display some jpg - pictures in a QPixmap.
On my Host machine it is working, but if I compile the program for QNX then the images are not loaded.
pixmap.load() returns "false".

There are no error messages or warnings when starting the program, so I don´t know what the problem could be..
As plugin there is "libqjpeg.so" under "usr/lib/qt4/plugins/imageformats"
And with QML, jpg´s are working.

Does anyone have an idea what I am doing wrong?

EDIT:

By using the shell the QML demo programs are running properly, but by using momentics to start the programs (and stopped shell) then I get also an error:

QQnxScreen: Attached to Device, number of displays: 1
QQnxScreen: Attached to Display 0, resolution 800x600, refresh 60 Hz
file:///tabs/content/tabs.qml:73:9: QML Image: Error decoding: file:///tabs/content/images/tab_r.jpg: Unsupported image format
file:///tabs/content/tabs.qml:48:9: QML Image: Error decoding: file:///tabs/content/images/tab_c.jpg: Unsupported image format
file:///tabs/content/tabs.qml:23:9: QML Image: Error decoding: file:///tabs/content/images/tab_l.jpg: Unsupported image format
Last edited by Noir on Wed Sep 25, 2013 10:04 am, edited 1 time in total.
Noir
Active Member
 
Posts: 31
Joined: Mon Aug 20, 2012 4:59 pm

Re: Displaying a .jpg picture in a QPixmap

Postby maschoen » Tue Sep 24, 2013 1:24 pm

Your post creates a number of questions.

What does "on my host it is working"? Is your host a Windows system or something else?
What do you mean by "using Momentics to start the program"? Are you starting the program on a QNX target system from Momentics on a host system?

Why does the error message have "file:///tabs/content/images/tab_r.jpg" as the format. "file:///..." is not part of the QNX file system. This prefix is a URL indicating that the resource should come from the local file system, but "file://" should not be there when passed to the QNX open() call. I don't know if this is just a confusion created by Qt or if something is actually wrong.

The error message suggests that JPEG support might not be compiled into Qt. This seems unlikely. I suspect that Qt uses libjpeg for this support, and so it might indicate that Qt is not finding or the libjpeg.so is missing from your target.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: Displaying a .jpg picture in a QPixmap

Postby Noir » Tue Sep 24, 2013 1:53 pm

here the answers to your questions:

- my host is indeed a Windows 8 machine
- I use QNX Momentics for compiling and sending the resulting binary to a beagleboard via ethernet. -> So, Yes I start the program from the host machine
- I don´t know why this error message is appearing, but this program was a demo from the QNX for Beagleboard demo available at foundry27

Further information:
I stop the shell at the begining, because it disrupts my communication via RS232.
The demo is running properly when started from shell. My program can also load the jpg´s but is not displaying anything.
Without the shell the mentioned error appears. So some environment variables are missing.
I tried to export in the .profile-file all variables I can see if I type "set" into the shell.
But it is still not working..
( "#" marks the point after which I added the variables)
export QWS_DISPLAY=qnx
export QWS_KEYBOARD=qnx
export TMPDIR=/ramdisk
export QWS_MOUSE_PROTO=qnx
export QT_PLUGIN_PATH=/usr/lib/qt4/plugins
export PATH=/proc/boot:/sbin:/bin:/usr/sbin:/usr/bin
###############################################
export RANDOM=4548
export SECONDS=64
export SHELL
export SYSNAME=nto
export TERM=vt100
export TMOUT=0
export TMPDIR=/ramdisk
export _=set
export GRAPHICS_ROOT=/usr/lib/graphics/omap3730
export HOME=/
export IFS='
export '
export KSH_VERSION='@(#)PD KSH v5.2.14 99/07/13.2'
export LD_LIBRARY_PATH=:/proc/boot:/lib:/usr/lib:/lib/dll:/opt/lib:/usr/photon/lib:/usr/photon/lib:/tmp
export MAILCHECK=600
export OPTIND=1
export PATH=:/proc/boot:/bin:/usr/bin:/opt/bin:/usr/photon/bin:/sbin:/usr/sbin
export PPID=1
export PS1='# '
export PS2='> '
export PS3='#? '
export PS4='+ '
export PWD=/


EDIT:
I played a little bit around with the setting and now the jpg´s are working if started with momentics.
The missing part was LD_LIBRARY_PATH and PATH in the "run configurator" as additional environment variable.
BUT if I start the binary from the board then the jpg´s cannot be loaded anymore.
This is confusing me a bit, because I could get the needed setings from the shell with "set".
Are these settings deleted if I kill the shell?
Noir
Active Member
 
Posts: 31
Joined: Mon Aug 20, 2012 4:59 pm

Re: Displaying a .jpg picture in a QPixmap

Postby maschoen » Tue Sep 24, 2013 5:58 pm

Ok, I think it is pretty clear right now. Your problem has to do with environment variables and specifically LD_LIBRARY_PATH.
The shell is merely a conduit for environment variables. When you start a program from the shell, it passes them on to the program being executed. If you start a program from somewhere other than the shell, you have to either create or pass them on yourself.

I think that what has happened is that the Qt routines are looking for libjpeg.so. If they are using the LD_LIBRARY_PATH to find then, and it's not set up right, they won't find it.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: Displaying a .jpg picture in a QPixmap

Postby Noir » Tue Sep 24, 2013 6:35 pm

Do you know a good way to give a program started on the Board these environment variables?
In my case I either make a bin which consists off
Code: Select all
cd /folder
./program_name -qws &


and start it via QNX momentics or I use a rc.local - file from the demo in which I can write some additional commands. These commands are executed after the startup script. There I start the aforementioned bin.

I already tried to execute the export commands, but this isn´t working. (In fact, it looks like a freeze of the OS )
Noir
Active Member
 
Posts: 31
Joined: Mon Aug 20, 2012 4:59 pm

Re: Displaying a .jpg picture in a QPixmap

Postby maschoen » Tue Sep 24, 2013 6:51 pm

You can set environment variables in the boot script, or if you use one in the rc.local script.
There's also shell syntax that sets a variable for a specific program, eg.:

LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dl ./program_name -qws &
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: Displaying a .jpg picture in a QPixmap

Postby Noir » Wed Sep 25, 2013 9:38 am

Ok Thanks alot maschoen :)

I don´t know what was going wrong before when I tried to export the variables in the rc.local script, but now it is working!
Noir
Active Member
 
Posts: 31
Joined: Mon Aug 20, 2012 4:59 pm


Return to GUI Programming

Who is online

Users browsing this forum: No registered users and 0 guests