Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it possible to display an image in console application in C++ using UNIX in background?
Or if you could help me out with the library in UNIX that enables us to include graphics in C++.
Please help...
Thanks in advance!!!
Posted
Updated 10-Nov-14 23:48pm
v2

1 solution

When using Linux, you can use the framebuffer[^].

To show an image using the framebuffer:

  • Open the framebuffer device (/dev/fbX)
  • Get the device information using ioctl calls with FBIOGET_FSCREENINFO and FBIOGET_VSCREENINFO
  • If necessary convert the image to the color depth of the framebuffer device (e.g. using the avconv utility)
  • Optionally scale the image
  • Map the device to memory using mmap
  • Copy the image data to the memory returned by mmap
  • Close the mapped memory
  • Close the device

If you need the image to be shown together with text, you should also draw the text using the framebuffer. Using normal console text output might overwrite parts of the image and may scroll the image out of view.

As library I would suggest Qt which supports multiple output methods including framebuffers.
 
Share this answer
 
Comments
sovit agarwal 11-Nov-14 6:49am    
Thanks Jochen!!!The information was very useful!!
But could you help me any material on this...any study material or codes..
have seen this for the first time...
Thanks a lot!!!
Jochen Arndt 11-Nov-14 7:00am    
It depends on the platforms / systems to be supported and what your application should display overall.

As a starting point you may also have a look at http://www.directfb.org/.
CPallini 11-Nov-14 7:49am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900