getpixel function returns the color of pixel present at location(x, y).
Declaration: int getpixel(int x, int y);
C program for getpixel
- int gd = DETECT, gm, color;
- char array;
- color = getpixel(0, 0);
- sprintf(array,"color of pixel at (0,0) = %d",color);
- return 0;
As we haven't drawn anything on screen and by default screen is BLACK, therefore color of pixel at (0,0) is BLACK. So output of program will be color of pixel at (0,0) is 0, as 0 indicates BLACK color.