显卡与帧的关系:由cpu调节其数据传输速率来输出其三基色的配比 。
三基色:RGB(红绿蓝) 。
在没有桌面和图形文件的系统界面,可以通过C语言的编程来实现在黑色背景上画图!
用下面的代码 , 在需要的地方(有注释)适当修改,就能画出自己喜欢的图形!
PS:同样要编译运行后才能出效果 。
#include stdio.h
#include sys/mman.h
#include fcntl.h
#include linux/fb.h
#include stdlib.h
#defineRGB888(r,g,b)((r0xff) 16 | (g0xff)8 | (b0xff))
#defineRGB565(r,g,b)((r0x1f) 11 | (g0x3f)5 | (b0x1f))
int main()
{
int fd = open("/dev/fb0", O_RDWR);
if(fd0){
perror("open err. \n");
exit(EXIT_FAILURE);
printf("xres: %d\n", info.xres);
printf("yres: %d\n", info.yres);
printf("bits_per_pixel: %d\n", info.bits_per_pixel);
size_t len = info.xres*info.yres*info.bits_per_pixel3;
unsigned long* addr = NULL;
addr = mmap(NULL, len, PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0);
if(addr == (void*)-1){
perror("mmap err. \n");
怎样用C语言画个圆?给你个画圆的例子
你参考一下
#include graphics.h
#include stdlib.h
#include stdio.h
#include conio.h
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int radius = 100;
/* initialize graphics and local variables */
initgraph(gdriver, gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk)/* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());
/* draw the circle */
circle(midx, midy, radius);
/* clean up */
getch();
closegraph();
return 0;
}
利用C语言编写 能够画出任意圆算法程序(利用画点函数)上次刚写过c语言画点函数画圆,在VC下运行c语言画点函数画圆的c语言画点函数画圆 ,
int
dx,dy,incrE,incrNE,d,x,y;
if
((point[1].x-point[0].x)==0){
//垂直c语言画点函数画圆的直线
x=point[0].x;
for(y=point[0].y;ypoint[1].y;y++)
pDC-SetPixel(x,y,50);
}
else
if(abs((point[1].y-point[0].y)/(point[1].x-point[0].x))=1){
//斜率
-1到
1
之间
dx=point[1].x-point[0].x;
dy=point[0].y-point[1].y;
d=dx-2*dy;
incrE=-2*dy;
incrNE=2*(dx-dy);
x=point[0].x,y=point[0].y;
pDC-SetPixel(x,y,50);
if(point[0].ypoint[1].y){
while(xpoint[1].x)
{
if(d=0){
d+=incrE;
x++;
}
else
{d+=incrNE;
x++;
y--;
}
pDC-SetPixel(x,y,50);
}
}
else
if(point[0].y=point[1].y){
dy=point[1].y-point[0].y;
incrE=-2*dy;
incrNE=2*(dx-dy);
x=point[0].x,y=point[0].y;
pDC-SetPixel(x,y,50);
while(xpoint[1].x)
{
if(d=0){
d+=incrE;
x++;
}
else
{d+=incrNE;
x++;
y++;
}
pDC-SetPixel(x,y,50);
}
}
}
else
{
//斜率
-1
和
1c语言画点函数画圆的直线
if(point[1].x=point[0].x){
dx=point[1].x-point[0].x;
dy=point[1].y-point[0].y;
d=2*dx-dy;
incrE=2*dx;
incrNE=2*(dx-dy);
x=point[0].x,y=point[0].y;
pDC-SetPixel(x,y,50);
while(xpoint[1].x)
{
if(d0){
d+=incrE;
y++;
}
else
{d+=incrNE;
pDC-SetPixel(x,y,50);
x++;
y++;
- mysqli获取所有数据 mysql的提取函数
- mysql 分组函数 mysql分组取数据
- mysql统计函数
- 将数据保存到文件中c语言 将数据保存到mongodb
- mysql有rank函数吗 mysql有rank
- redis-cli命令不能用 redis函数调用失败
- 罗布人村天气 mysql语言具有的功能
- mysql的判断函数 mysql怎么判断奇偶数
- mysql数据库编码格式查询 mysql编码函数
- mysql日期yyyymmdd mysql中的日期型函数
