getpixel() function is used to get the color of pixel present at any specified location (x,y).
- It contains two arguments, first argument represents the X-coordinate and second argument represents the Y-coordinate.
- For better understanding go through the program:
int gd=DETECT, gm,col;
sprintf(a,”color of pixel at location (320,240) is %d”,y);
The above program firstly plots the pixel of red color on the location (320,240). Now for getting the number associated with the color of pixel we used getpixel() function in the program. getpixel() includes two arguments 320 (X-coordinate) and 240 (Y-coordinate) which shows the position of the red color pixel. getpixel() function stores the number associated with red color in the integer type variable col then sprintf() and outtextxy() function together print the “color of pixel at location (320,240) is 4″at location (30,100).