• C

Plot a pixel in Linux

I want to know how to access various graphics modes and plot a pixel in C under Linux platform.

I do not want to use any library other than the standard libraries provided by gcc. This is not part of any assignment or project. I just want to learn how to do it. I have tried reading the source code of standard libraries but it has not been helpful. Can someone guide me here ?

I am also posting a link to this question in the Linux programming section.

Thanks for your help.

Dhyanesh
LVL 4
dhyaneshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Karl Heinz KremerCommented:
You need to learn about how to switch the display mode, and then use the framebuffer directly. I would suggest that you read code to learn how to do that. The Linux framebuffer driver should have all this information. You can find it in your Linux source tree in the ./drivers/video directory. The standard libraries don't support this, but the fb console does.
0
dhyaneshAuthor Commented:
Hi

Thanks for your comment khkremer.

When I mentioned I tried reading source code of standard libraries I actually meant graphic libraries like SDL which are available for graphics in Linux. I would like a bit of explanation of how the code works. I will read the code of the Linux framebuffer driver but if someone can explain it, it would be better.

Dhyanesh

0
Karl Heinz KremerCommented:
Sorry about that, I thought that you did read things like the "standard library that comes with every C compiler - as defined by the C standard". I have to admit that I never even tried to create a pixel "the hard way". However, I did this back in the DOS days

Take a look at this page, it shows how to paint pixels using the framebuffer device, they even have a sample program near the end of the page that does just that.
0
The Lifecycle Approach to Managing Security Policy

Managing application connectivity and security policies can be achieved more effectively when following a framework that automates repeatable processes and ensures that the right activities are performed in the right order.

dhyaneshAuthor Commented:
Hi

I do want to know how to create a pixel the hard way. I know how to do it in DOS. Using int 10h interrupt and with framebuffer starting at 0xA0000000.

You have not given the link to the page you are mentioning.

Dhyanesh
0
Karl Heinz KremerCommented:
I'm sorry about that. Here is the link:

http://doc.trolltech.com/3.0/emb-framebuffer-howto.html

.. and another one:

http://l4fdyos.ciwunion.com/ARTICEL/Linux%202.2%20Framebuffer%20Device%20Programming%20Tutorial.htm

... and a Linux magazine article about the frame buffer device in general:

http://www.linux-magazine.com/issue/03/EmbeddedGraphics.pdf

Again, I'm sorry about the missing link.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kent OlsenData Warehouse Architect / DBACommented:
Hi dhyanesh,

DOS output to the terminal is completely different than linux output.  Linux has no equivalent to a DOS interupt that will diddle a particular pixel.

You'll have to work within whatever graphics mode you're using.  Under linux, this is almost always X (X11) an is included with most linux distributions in XLIB.

  Image = ECreateImage ();
  XInitImage (Image);
  XPutPixel (Image, X, Y, PixelCharacteristics);

Will do what you want.  But you'll be dealing with the image (window) that you create.


Kent
0
dhyaneshAuthor Commented:
Hi

I am checking out the links given by  khkremer. Please give me some time to go through them.

I will also try out what you have posted, Kent. I have RedHat 7.1 and X Windows system so most probably I will be having XLIB

Dhyanesh
0
Karl Heinz KremerCommented:
If you want to go the X11 route, the three lines given by Kdo will not give you a working program. There is quite a bit of code that's required to create even the most simple X11 program.
0
dhyaneshAuthor Commented:
Hi

If possible please do post the code for X11 also. However as I just brushed through the third link you sent i.e. the PDF document I found that the X11 route is indirect involving quite a few steps involving network layer, decoder, X-server etc.

I will go through the method you have posted first. I hope you do not mind if I take a bit time to respond again as I am a bit busy now. Also I will take some time before closing this question.


Dhyanesh
0
Karl Heinz KremerCommented:
Look at this link: http://www-h.eng.cam.ac.uk/help/tpl/graphics/Summary.html_old

Search for the string "A SAMPLE X11 PROGRAM WRITTEN IN C" in this document (it's about half way down). It shows a sample program (written in C - just as the title says :-) It draws a line and displays a string. You should be able to add the three lines from above.
0
Kent OlsenData Warehouse Architect / DBACommented:

Hi dhyanesh,

khkremer is correct that the three line snippet that I gave isn't sufficient to give you a working program.  (I also seem to have trouble spelling 'XCreateImage', but that's another matter. :) )

I've got an entire X11 "console" that I can post or send to you but it's fairly long.  The link provided above gives a much shorter program.  (I like it.)  Plugging XPutPixel() into it shouldn't be tough.


Kent
0
dhyaneshAuthor Commented:
Thanks for your posts I will reply in detail after two three days. Hope that is fine

Dhyanesh
0
dhyaneshAuthor Commented:
Sorry for the delay but I have a problem. I have study leave at present and do not have access to a Linux Box. I will be able to try out your suggestions by start of January.

Do not worry I will not abandon this question . I will definitely give points to one person or the other.

Dhyanesh
0
manish_regmiCommented:
hi,
 try looking at the sources of svgalib.
http://www.svgalib.org/
0
dhyaneshAuthor Commented:
As this question is 1000 points. I split it Kdo - 250 and  khkremer  - 750

khkremer get your remaining 500 points here

http://www.experts-exchange.com/Programming/Programming_Languages/C/Q_20813999.html

Dhyanesh

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.