LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-21-2005, 03:15 PM   #1
mic
Member
 
Registered: Jun 2005
Posts: 44

Rep: Reputation: 16
Display an image in C, fullscreen


Hi, linux programmers,

I need to write some C or C++ code that (on some events) displays a png file on fullscreen. Preferably without X, on the framebuffer. I found fbida and fbv, but:
  • it doesn't seem too simple how they do it
  • I can't even compile the code of neither of them, I get tons of errors
  • the license is GPL. I'd prefer BSD or LGPL so I could use their code or simply use their libs. In this case GPL is good only to learn how this is done, so I could then write my own code
Can you give me any directions or examples how to do this? Decoding png could be probably accomplished with libpng, which is LGPL. I'm more concerned about displaying the image on framebuffer. If really, really necessary, I could use X, but I'm trying to avoid using X at all costs here.

Thanks for any help.

Last edited by mic; 06-21-2005 at 03:17 PM.
 
Old 06-21-2005, 03:53 PM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
If you do have to use X, then you might look into the framebuffer server, or possibly a non-XFree86/XOrg distro, to reduce the overhead.

You can certainly do this. DirectFB (LGPL) should be up to the job I think.

Alternatively, it would probably be easier, and more portable, to write your program using the SDL library, which takes care of a lot of the hassles for you.

Another option is fbi (GPL) or ppmtofb (GPL, more specifically fbview) which you could shell out to to show the image. (There's a legal minefield here as to whether this counts as linking or not; one possibility is to make the viewer configurable but I'm not a legal expert and I don't know if that will get you out of trouble).

Yet another option is to write a kernel module to do it (after decompressing the PNG in userspace); you'll find an entire pixmap-drawing library in drivers/video/cfbimgblt.c

You might also want to try searching on freshmeat.net
 
Old 06-23-2005, 03:52 AM   #3
mic
Member
 
Registered: Jun 2005
Posts: 44

Original Poster
Rep: Reputation: 16
Thank you very much. I went for SDL, it seems fast enough. Got some huge problems (I'm an SDL newbie) with enabling fb in debian sarge and geting SDL_Init to succeed without mouse, but got it now.
 
Old 05-29-2008, 04:02 AM   #4
contente
LQ Newbie
 
Registered: May 2008
Posts: 2

Rep: Reputation: 0
Hello!

I'm sorry about reliving an old thread but I have the same problem.
I need a program in C that displays fullscreen images.

mic can you help me?!
 
Old 05-29-2008, 04:26 AM   #5
mic
Member
 
Registered: Jun 2005
Posts: 44

Original Poster
Rep: Reputation: 16
Hi contente,

if you are doing this without X as I did, you need framebuffer support in kernel. Look for options CONFIG_FB* when you configure the kernel.

Install SDL and SDL_image.

If you will use framebuffer and are missing fb0 device node, create it:
Code:
mknod -m 666 /dev/fb0 c 29 0
I had some difficulties (lockups, errors, can't remember what exactly) because I didn't have a mouse attached. I had to set this environment variable before running my SDL program.
Code:
export SDL_NOMOUSE=1
For info about writing C code that works with SDL, see the documentation on SDL website. There should be some example code, like Hello World.
 
Old 05-29-2008, 11:33 AM   #6
seraphim172
Member
 
Registered: May 2008
Posts: 101

Rep: Reputation: 15
SVGALIB is a quite archaic piece of code, but not as complex as SDL, and it runs without X. It not used often these days, but if your interest in rather in learning the concept, then it's maybe worth a look.

As of the license: You can use GPL code and libs, unless you intend to go commercial with code written by others. Even then you can link your application to shared GPL libraries. Only advantage of LGPL for commercial purposes is that you can link them statically if the code of the library itself didn't changed.

It seems you're at the start position with your coding project. Isn't it too early to bother with licenses?

Linux Archive

Last edited by seraphim172; 06-25-2008 at 04:40 AM.
 
Old 05-29-2008, 07:27 PM   #7
mic
Member
 
Registered: Jun 2005
Posts: 44

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by seraphim172 View Post
As of the license: You can use GPL code and libs, unless you intend to go commercial with code written by others. Even then you can link your application to shared GPL libraries. Only advantage of LGPL for commercial purposes is that you can link them statically if the code of the library itself didn't changed.

It seems you're at the start position with your coding project. Isn't it too early to bother with licenses?
As I understand, you can't use GPL code, nor link to GPL libs if your program is non free.
http://www.gnu.org/licenses/gpl-faq.html#IfLibraryIsGPL

Besides, only I was concerned about license and I finished my project long ago. So as far as this thread is concerned, the license issue is probably irrelevant.
 
Old 05-30-2008, 05:04 PM   #8
seraphim172
Member
 
Registered: May 2008
Posts: 101

Rep: Reputation: 15
Quote:
If a library is released under the GPL (not the LGPL), does that mean that any program which uses it has to be under the GPL?
Yes, because the program as it is actually run includes the library.
Hmm, yes .. well, Apache uses it's own license and still uses the GNU C libraries. Same for OpenOffice. This is an endless topic. I never heard of Eben Moglen stressing a law suite against Apache or OpenOffice developers.

The FAQ is actually a bit vague, as it confuses the term "using a library" without going into detail on static and shared libraries. A static library becomes part of the compiled code and moves along with it. A shared library is accessed at runtime.

You could create an application that uses a shared library called 'libc' by calling a function called 'malloc' and 'free'. C, malloc and free are standard C terms and are not subject to GPL. Assume that on one system libc is provided by GPL code, on another system by BSD code or something else. Your application can be copied between those two systems, will always find a libc with the proper malloc and free implementation, so it will work. You as a developer can not be made responsible for a shared service provided on any of those systems - the same compiled code can not be illegal on one system while being legal on another one.

Note how different this is from a situation where the library is statically linked, so it becomes part of the application and does not use the libc implementation provided by the running system.
 
Old 06-01-2008, 09:57 AM   #9
contente
LQ Newbie
 
Registered: May 2008
Posts: 2

Rep: Reputation: 0
Question

i want to use X anyone can help me?
i want to load an pnm image in full screen.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
XMAME Fullscreen Display Methods erraticassassin Linux - Games 17 01-24-2012 03:39 PM
Image display in Evolution djmurray Linux - Newbie 1 10-08-2007 07:46 PM
java - howto display an image and find mouse coords on it? titanium_geek Programming 6 06-04-2005 11:41 AM
Laptop LCD display problems - Unuseable image alxp Linux - Hardware 1 10-17-2004 06:50 AM
Mplayer: 704x576 image cannot fit on 800x600 display? J_Szucs Linux - Software 0 03-27-2004 07:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration