Click here to Skip to main content
15,915,328 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am a student from China,this is the first time I visit this great website:).
My question is:
How to display a picture or draw a single point with C Standard Library?
The codes must can be complied by dev-cpp(gcc),and can run in windows.
I find these codes,but they can display a char (In my opinion,if it can display a char ,I can use it to display a picture :)).

unsigned char *screen=(unsigned char *)0xb8000;
void putch(char ch,char color, int x, int y)
{
  unsigned char *temp=screen;
   temp+=+(80*y+x)*2;  
   *temp++=ch;  
   *temp=color;  
}



Thanks!!!
Posted

Your opinion is wrong. C++ has NO facilities for graphics, windows, etc. Nor does C. C was developed to run on systems that were text only. Even C++ is designed to not require a system to have a graphical interface. What you want, cannot be done.
 
Share this answer
 
The C standard library is a set of function to manage raw text and handle simple input / output.
There is no "graphic" in it.

The code you provide is an implementation of a generalization of putch function (that puts a characted on the standrd output) that operates on Text-Mode color displays. (Today they exist as "virtual" into a graphic context, that's hidden by the operating system)

If you really want to do graphics, you should interact with the underlying operating system using proper API - not so easy for a beginner: lots of concepts behind, and very good knoweledge of C at all levels (one thing to make you scary: pointer to functions), or using multi platform libraries (WxWidgets, GTK, QT to tell just a bunch of them) providing their own API and implementing themselves the mapping toward the underlying OS.

I suggest you to read some "Windows Programming" books or tutorials (just google for them) just to make an idea on what I mean.
 
Share this answer
 

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