炀湖北理工姚莉嵌入式实训.docx
- 文档编号:26270824
- 上传时间:2023-06-17
- 格式:DOCX
- 页数:8
- 大小:15.09KB
炀湖北理工姚莉嵌入式实训.docx
《炀湖北理工姚莉嵌入式实训.docx》由会员分享,可在线阅读,更多相关《炀湖北理工姚莉嵌入式实训.docx(8页珍藏版)》请在冰豆网上搜索。
炀湖北理工姚莉嵌入式实训
Fb8.c
#include
#include
#include
#include
#include
#include
#include
#include
#include
intw,h,bpp;
int*fbmem,*obuf32;
voidfb_point(intx,inty,intcolor32)
{
fbmem[y*w+x]=color32;
}
voidclean()
{
inti,j;
for(i=0;i for(j=0;j fb_point(i,j,0); } //A8: 24-32 intrgb24to32(intcolor24) { intcolor32; intr24,g24,b24,r32,g32,b32; r24=color24&0xff; g24=(color24>>8)&0xff; b24=(color24>>16)&0xff; r32=r24; g32=g24; b32=b24; color32=(r32<<16)|(g32<<8)|b32; returncolor32; } //A8: buf24to32() int*buf24to32(unsignedchar*buf24,intimagew,intimageh) { inti,j,color24; intcolor32; int*buf32; buf32=(int*)malloc(imagew*imageh*sizeof(int*)); for(j=0;j for(i=0;i { color24=*(int*)buf24; color32=rgb24to32(color24); buf32[j*imagew+i]=color32; buf24+=3; } returnbuf32; } voidscale(int*buf32,intimagew,intimageh) { inti,j,imagei,imagej; for(j=0;j for(i=0;i { imagei=i*imagew/w; imagej=j*imageh/h; obuf32[j*w+i]=buf32[imagej*imagew+imagei]; } } unsignedchar*decode_jpeg(char*filename,short*widthPtr,short*heightPtr); voiddisplay1(char*filename) { inti,j;//1.jiema shortimagew,imageh; unsignedchar*buf24; int*buf32; buf24=decode_jpeg(filename,&imagew,&imageh); buf32=buf24to32(buf24,imagew,imageh); scale(buf32,imagew,imageh); for(i=0;i { for(j=0;j { fb_point(i,j,obuf32[j*w+i]); } usleep(10000); } } voiddisplay2(char*filename) { inti,j,r1,r2,r3,r4; shortimagew,imageh; unsignedchar*buf24; int*buf32; r1=w/5;r2=w/5*2;r3=w/5*3;r4=w/5*4;//1.jiema buf24=decode_jpeg(filename,&imagew,&imageh); buf32=buf24to32(buf24,imagew,imageh); scale(buf32,imagew,imageh); for(i=0;i<=w/5;i++)//2.xianshi { r1++; r2++; r3++; r4++; for(j=0;j { fb_point(i,j,obuf32[j*w+i]); fb_point(r1,j,obuf32[j*w+r1]); fb_point(r2,j,obuf32[j*w+r2]); fb_point(r3,j,obuf32[j*w+r3]); fb_point(r4,j,obuf32[j*w+r4]); } usleep(10000); } } voiddisplay3(char*filename) { inti,j,k; shortimagew,imageh; unsignedchar*buf24; int*buf32; k=h-1; buf24=decode_jpeg(filename,&imagew,&imageh);//1.jiema buf32=buf24to32(buf24,imagew,imageh); scale(buf32,imagew,imageh); for(j=0;j<=h/2;j++)//2.xianshi { for(i=0;i { fb_point(i,j,obuf32[j*w+i]); fb_point(i,k,obuf32[k*w+i]); } k--; usleep(10000); } } intmain(intargc,char*argv[]) { intfbfd; structfb_var_screeninfofb_var; fbfd=open("/dev/fb0",O_RDWR); printf("fbfd=%d\n",fbfd); ioctl(fbfd,FBIOGET_VSCREENINFO,&fb_var); w=fb_var.xres; h=fb_var.yres; bpp=fb_var.bits_per_pixel; printf("%d*%d-%d\n",w,h,bpp); obuf32=(int*)malloc(w*h*bpp/8); fbmem=mmap(0,w*h*bpp/8,PROT_READ|PROT_WRITE,MAP_SHARED,fbfd,0); clean(); display1("test1.jpg"); clean(); display2("test2.jpg"); clean(); display3("test3.jpg"); close(fbfd); return0; } Makefile #hello: hello.c #gcchello.c-ohello #hello: hello1.ohello2.o #gcchello1.ohello2.o-ohello #hello1.o: hello1.c #gcc-chello1.c-ohello1.o #hello2.o: hello2.c #gcc-chello.c-ohello2.o #.PHONY: clean #clean: #rmhello1.ohello2.ohello # src=$(wildcard*.c) obj=$(patsubst%.c,%.o,$(src)) target=app CC=gcc #CC=arm-linux-gcc CFLAGS=-c-Wall-I/root/jpeg-8b/ LFLAGS=-ljpeg-L/root/jpeg-8b/.libs/ $(target): $(obj) $(CC)$^-o$@$(LFLAGS) %.o: %.c $(CC)$(CFLAGS)$<-o$@ clean: -rm-f$(obj)$(target)
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 湖北 理工 嵌入式