How to Draw a Pixel in Graphics

How to Draw a Pixel in Graphics

In this example, you will get a c program to draw a pixel in graphics. Here we will use putpixel() function to print a pixel on the screen. This program can be run by using Turbo C++ and Dev C++ compiler. Here we will use Turbo C++ compiler, you can also use Dev C++ compiler to run this program.
 
Draw a Pixel in Graphics

 

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

Output :

pixel in graphics

 

 

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top