Read pixel color using getpixel function in C

Read pixel color using getpixel function in C

In this example, you will know about getpixel() function and get program code to read pixel color using getpixel function in c programming. We will be using turbo c++ compiler to make this program.
 
use of getpixel function in c program

 

C program to Read Pixel Color in Graphics

In Graphics, putpixel function is used print the pixel in graphics on screen, But if we want to read the pixel color from a particular location, for that purpose graphics library provide us a function named as getpixel

getpixel function is used to pick the pixel color from the location of given coordinates.

for Example:-

mycolor=getpixel(100,200) will pick the color of pixel from 100, 200 location of screen.

getpixel function is also used to work with mouse movement and mouse click(same like paint brush) in the window.

Program code to read pixel color using getpixel function in c

Output:
use of getpixel function in c program output

 

Leave a Comment

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

Scroll to Top