Tuesday, October 7, 2008

How To Display JPEG Image on Linux console


Linked From www.2beanet.com

How To Display JPEG Image on Linux console


1 Summary
Usually, we can't display graphics images on linux console, in order to see graphics images, take
viewing jpeg graphics images for example, we should start the x-windows, using the tools for viewing
graphic images supplied by the desktop management system such as gnome or ked .
and so, whether we can viewing graphics images on linux console? In fact , it is throughly possible.
As we know, there is tool for viewing graphics imags working on linux console whose name is zgv.
But, since the low level graphics lib it uees is too old that few people know it , the people use it is more less.
Now , the low level graphics lib is supplied by FrameBuffer, so I try to explain how to deisplay jpeg
on linux console by framebuffer and lib jpeg. The experience is what I have tested correctly.
2 FrameBuffer Description
FrameBuffer is realized as device under linux, it is abstrication for the graphics hardware, representing
the frame buffer in the display cards.By framebuffer device, the upper application may using a well
defined software interface to access the graphics hardware, but not need to take care of how the low
level graphics hardware works.For example, the upper application don't have to know how to read and
write the register of the display cards, nor have to know where the frame buffer district start from, all
these works is dealt with frambuffer, the upper application only pay attention to what it should do.
The advantage of FrameBuffer is that it is a low level usual device, and it supports many platforms,
it can works on x86 platforms, powerpc platforms, and m68k and sparc as well, it also work correctly on
many embedded devices. Many GUI software package such as Minigui also take FramBuffer for its
HardWare Abstrication Layer.
From the viewer of the users, frambuffer device has no difference from other devices.Framebuffer
devices resides under '/dev' directory, usual device name is fb*, here, * take the value from 0 to 31.
For usual computer system, 32 framebuffer devices are suffication.The most used framebuffer device is
'/dev/fb0'.
From the viewer of programmer, Framebuffer device is a file in fact, we could read and write
Framebuffer device file as we operate usual file, we could remap it into memory by mmap() function,
also read and set its parameters by using ioctl() function, and so on.
In order to start framebuffer on pc system, first of all, it should be supported by the kernel, usually , we
should recompile the kernel. Also, we should modify the start parameter, on my personal machine, I
modify the file /boot/grub/menu.lst, change the line below
kernel /boot/zImage-2.6.25 rw root=LABEL=/1 to the new line below
kernel /boot/zImage-2.6.25 rw root=LABEL=/1 vga=0x314
what it means is that the resolution of the display is 800x600, the color depth is 16bits.
3. program
Pls download the source file from here:

No comments: