void fb_drawfpage(PFBDEV pFbdev,int x,int y, u32_t color) { int i=0; for (i = x; i < 500; i++) { if(i%10==9) { fb_drawvline(pFbdev,i,100,0x00ff0000); } else { fb_drawvline(pFbdev,i,100,color); } } }
void fb_drawhline(PFBDEV pFbdev,int x,int y,u32_t color) { int i; for (i = 0; i < pFbdev->fb_var.xres; i++) { fb_drawpixel(pFbdev,i,y,color); } return; int fb_line(int x1,int y1,int x2,int y2,u32_t color) { int dx=x2-x1; int dy=y2-y1; int p=0; int inc=((dx*dy<0)?-1:1); if(abs(dx)>abs(dy)) { if(dx<0) { swap(&x1,&x2); swap(&y1,&y2); dx=-dx; dy=-dy; } dy=abs(dy); p=2*dy-dx; while(x1<=x2) { fb_one_pixel(x1,y1,color); x1++; if(p<0) { p+=2*dy; } else { y1+=inc; p+=2*(dy-dx); } } } else { if(dy<0) { swap(&x1,&x2); swap(&y1,&y2); dx=-dx; dy=-dy; } dx=abs(dx); p=2*dx-dy; while(y1<=y2) { fb_one_pixel(x1,y1,color); y1++; if(p<0) { p+=2*dx; } else { x1+=inc; p+=2*(dx-dy); } } } return 0; int main(void) { FBDEV fbdev; memset(&fbdev,0,sizeof(FBDEV)); strcpy(fbdev.dev,"/dev/fb0"); if (fb_open(&fbdev)==FALSE) { printf("open frame buffer error\n"); return; } fb_memset((void *)(fbdev.fb_mem + fbdev.fb_mem_offset),0,fbdev.fb_fix.smem_len); //画点 fb_drawpixel(&fbdev,512,384,0x00FF0000); fb_drawpixel(&fbdev,513,384,0x00FF0000); fb_drawpixel(&fbdev,512,385,0x00FF0000); fb_drawpixel(&fbdev,513,385,0x00FF0000); //画垂直线 fb_drawvline(&fbdev,511,380,0x0000ff00); fb_drawhline(&fbdev,380,200,0x000000ff); fb_close(&fbdev); getchar(); }