You are here

getpixel and putpixel functions in C

int getpixel(int x, int y);
void putpixel(int x, int y, int color);

Function getpixel returns the color of pixel present at point(x, y).
Function putpixel plots a pixel at a point(x, y) of the specified color.

C programming code for getpixel and putpixel


int main()
   int gd = DETECT, gm, x = 100, y = 100, color;
   char arr[100];


   putpixel(x, y, RED);

   color = getpixel(x, y);

   sprintf(arr,"Color of pixel located at point(%d, %d) is %d",x,y,color);

   return 0;