How to Draw a Pixel in Graphics
![Draw a Pixel in Graphics Draw a Pixel in Graphics](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhd0jDiMIXUqOSQFaeDE3ljBhVhIoRBaOb_-KgrcKqe0mVleD6IkcCccbKUSDzIQ9g-TB-pvMWBnrX_QAtdU_FVl_TsvfbvWpFCM3DR0_KmOrGDlptPELUTztXMNMTbCi5oKQHLM2gIzPvYK0Nw9UNBDMmlsorH6jyFdDmhCqUMJANQSIx54xJb84X_/w640-h336/draw-pixel-in-graphics.png)
What is Pixel in Computer Graphics
Pixel is a term used to describe the smallest unit of a digital image or graphic. It is the smallest individual component in an image. Each pixel is typically represented by a single number or color, which together form an image.
How to Draw Pixel in Graphics?
The simplest way to draw a pixel in C Graphics is to use the putpixel() function. This function takes three parameters, the x coordinate, the y coordinate of the pixel, and color of single pixel on the screen at the specified coordinates.
This program is the first program of Computer Graphics in C. It is also a good example of putpixel function of graphics library. In this program, we are going to draw a pixel in graphics of Red color on the X,Y location of the screen
Syntax:
void putpixel(x,y,color);
here:
x and y are the coordinates of the pixel and color is the color that you want the pixel to be.
Example:
putpixel(100, 100, RED);
This statement will draw a red pixel at the coordinates (100,100).
Program code to Draw a Pixel in Graphics
1 2 3 4 5 6 7 8 9 10 11 12 | //C Program to Draw Pixel in Graphics. #include<graphics.h> #include<stdio.h> #include<conio.h> void main( ) { int gd = DETECT, gm; initgraph(&gd, &gm, "C:\TURBOC3\BGI"); putpixel(100,100,RED); getch( ); closegraph(); } |
Output :
![pixel in graphics pixel in graphics](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMXt4W6bnpEiYeRDI3jWlh8AsjsTZBBQWcoR3x3qxY_M3AQLFTxb32_KU252zc1l2_X1N1sEu4NsU4mKeQTmxoA1HdCxQ4xy7LwEhSK1UGjURDGmo3EYFypo_MZ2NWNq15b-u2q34S4K6K62KQ6k82AyxVs-y23RE5sMExulgGDvSilfDVKlGPM7Ia/w640-h288/putpixel-in-c-output.png)