Write a function void DrawRectangle(char *Screen, int x1, int y1, int x2, int y2). Height and width of the monitor is known. To set a pixel, you need to set that particular bit of the screen.
Monitor is char array. Suppose you want to set a pixel at (10,0), Screen[0]=00000000 Screen[1]=01000000(10th bit from left is set)
#Define hight 100
#Define width 200
void (char *screen, int x, int y)
{
if( y >=hight || x>=width)
return;
screen[y*width]+x = 1;
}
void DrawRectangle(char *Screen, int x1, int y1, int x2, int y2)
{
for( int i=x=y1; i<=y2; ++i)
{
for(int j=x1;j<=x2; ++J)
{
setPixel(Screen,i,j);
}
}
}
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks