I am creating bitmap / bmp files according to the specifications with my C code, and I would like to draw simple primitives on my bitmap. The following code shows how I draw a rectangle in my bitmap:
if(curline->type == 1) // draw a rectangle { int xstart = curline->x; int ystart = curline->y; int width = curline->width + xstart; int height = curline->height + ystart; int x = 0; int y = 0; for(y = ystart; y < height; y++) { for(x = xstart; x < width; x++) { arr[x][y].blue = curline->blue; arr[x][y].green = curline->green; arr[x][y].red = curline->red; } } printf("rect drawn.\n"); } ... save_bitmap();
Output Example: 
So basically I set the red, green, and blue values ββfor all the pixels in the given x and y.
Now I would like to fill the circle, knowing its middle and radius. But how do you know which pixels are inside this circle and which are not? Any help would be appreciated, thanks for reading.
source share