通过全志R16平台TINAV2.1下的LCD显示BMP图片(分色排版)V1.0版本
来源:互联网 发布:淘宝超时发货赔付规则 编辑:程序博客网 时间:2024/05/17 01:36
通过全志R16平台TINAV2.1下的LCD显示BMP图片
2017/7/3 14:25
请严重注意前两点:
1、红绿蓝的顺序,BMP格式的图片和LCD显示屏是一样的。
2、BMP的图片显示顺序:从左下(坐标原点)开始,最后到右上。LCD的坐标原点是左上。如果不注意,会出现图片显示的效果是上下对称反的情况!
3、为了简单起见,将禁止休眠的指令:echo on > /sys/power/state在程序里面通过system这个系统调用来实现了!
4、直接将/bin/1.bmp这幅图片在LCD上面显示了。使用的是fread函数,没有使用memcpy等系统的库函数,可以优化!
1、原始编译:
rootroot@cm-System-Product-Name:/home/wwt$ cd display_tinav2.1/
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ source build/envsetup.sh
including target/allwinner/tulip-d1/vendorsetup.sh
including target/allwinner/octopus-sch/vendorsetup.sh
including target/allwinner/azalea-perf2/vendorsetup.sh
including target/allwinner/azalea-perf3/vendorsetup.sh
including target/allwinner/octopus-dev/vendorsetup.sh
including target/allwinner/astar-evb/vendorsetup.sh
including target/allwinner/generic/vendorsetup.sh
including target/allwinner/azalea-perf1/vendorsetup.sh
including target/allwinner/astar-parrot/vendorsetup.sh
including target/allwinner/astar-spk/vendorsetup.sh
including target/allwinner/azalea-evb/vendorsetup.sh
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ lunch
14. astar_parrot-tina
Which would you like?14
============================================
PLATFORM_VERSION_CODENAME=Neptune
PLATFORM_VERSION=2.0.0
TARGET_PRODUCT=astar_parrot
TARGET_BUILD_VARIANT=tina
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=cortex-a7
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_BUILD_TYPE=release
BUILD_ID=57513AA3
OUT_DIR=
============================================
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ make -j12
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ pack -d
2、编译uboot,重新烧录启动之后就可以看见图标!(已经打uboot显示图标的patch!)
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ cd lichee/brandy/
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/lichee/brandy$
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/lichee/brandy$ ./build.sh -p sun8iw5p1
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/lichee/brandy$ cd -
/home/wwt/display_tinav2.1
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ pack -d
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$
3、增加fb_test显示BMP图片的这个应用程序:
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ cd package/allwinner/
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/package/allwinner$
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/package/allwinner$ unzip FB测试程序.zip
Archive: FB测试程序.zip
inflating: diff.patch
inflating: src.zip
inflating: ╦╡├ў.txt
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/package/allwinner$
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/package/allwinner$ unzip src.zip
Archive: src.zip
inflating: allwinner/fb_test/Makefile
inflating: allwinner/fb_test/src/Makefile
inflating: allwinner/fb_test/src/main.c
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/package/allwinner$
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/package/allwinner$ cd allwinner/
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/package/allwinner/allwinner$mv fb_test/ ..
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/package/allwinner/allwinner$cd ..
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/package/allwinner$ rm allwinner/ -rf
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/package/allwinner$
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/package/allwinner$ cd ../..
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ cp .config bak1_orig.config
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ source build/envsetup.sh
including target/allwinner/tulip-d1/vendorsetup.sh
including target/allwinner/octopus-sch/vendorsetup.sh
including target/allwinner/azalea-perf2/vendorsetup.sh
including target/allwinner/azalea-perf3/vendorsetup.sh
including target/allwinner/octopus-dev/vendorsetup.sh
including target/allwinner/astar-evb/vendorsetup.sh
including target/allwinner/generic/vendorsetup.sh
including target/allwinner/azalea-perf1/vendorsetup.sh
including target/allwinner/astar-parrot/vendorsetup.sh
including target/allwinner/astar-spk/vendorsetup.sh
including target/allwinner/azalea-evb/vendorsetup.sh
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ lunch
14. astar_parrot-tina
Which would you like?14
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ make menuconfig
Allwinner --->
< > fb_test.......................................... is framebuffer bin file (NEW)
修改为:
<*> fb_test.......................................... is framebuffer bin file
Kernel modules --->
Video Support --->
< > kmod-sunxi-disp....................................... SUNXI-DISP support
< > kmod-sunxi-lcd......................................... SUNXI-LCD support
修改为:
-*- kmod-sunxi-disp....................................... SUNXI-DISP support
<*> kmod-sunxi-lcd......................................... SUNXI-LCD support
(已经打开:)
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ cp .config bak2_disp.config
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ cd lichee/linux-3.4/
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/lichee/linux-3.4$
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/lichee/linux-3.4$ cp .config bak1_orig.config
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1/lichee/linux-3.4$ cd -
/home/wwt/display_tinav2.1
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ make kernel_menuconfig
Device Drivers --->
Graphics support --->
<*> Support for frame buffer devices --->
Video support for sunxi --->
<M> DISP Driver Support(sunxi)
[ ] Framebuffer Console Support(sunxi)
<M> LCD Driver Support(sunxi)
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ make -j12
rootroot@cm-System-Product-Name:/home/wwt/display_tinav2.1$ pack -d
4、重新烧录之后,通过adb push将1.bmp传送到/bin/目录下(不需要修改属性)。
请注意:1.bmp是1280x800分辨率。
图片来源:
百度搜索关键词:1280x800,即可获得大量的1280x800分辨率的JPG格式的图片,可以通过windows自带的画图/mspaint或者ACD SEE等等转换为bmp格式的图片。
或者使用Photoshop/GIMP等等图片编辑软件来裁剪现有的图片。
Microsoft Windows [版本 6.1.7600]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Users\Administrator>cd D:\360极速浏览器下载\1280x800
C:\Users\Administrator>d:
D:\360极速浏览器下载\1280x800>adb push 1.bmp /bin/
8403 KB/s (3072054 bytes in 0.357s)
D:\360极速浏览器下载\1280x800>
在串口执行fb_test,即可看见全红/全绿/全蓝/您发送到系统里面的图片交替出现:
root@TinaLinux:/# fb_test
[ 7783.934037] request_suspend_state: wakeup (0->0) at 7783934016547 (1970-01-05 12:17:49.569918251 UTC)
fb0 begining
readCnt = 1
****wyb 2017/7/3 9:36 x = 1280 y = 800 bytes_per_pixel = 4
screensize = 4096000
----- RED 0
----- GREEN
----- BLUE
----- RED 1
----- GREEN
----- BLUE
^C
root@TinaLinux:/#
5、常见错误:
root@TinaLinux:/#
root@TinaLinux:/# pwd
/
root@TinaLinux:/#
root@TinaLinux:/# fb_test
[ 7945.097615] request_suspend_state: wakeup (0->0) at 7945097595373 (1970-01-05 12:20:30.733496827 UTC)
fb0 begining
Segmentation fault
root@TinaLinux:/#
(您忘记经将1.bmp通过adb push到/bin/下了。通过adb push进去之后,再次执行fb_test即可!)
参考资料:
http://baike.baidu.com/link?url=afkmkmYkclixDWOVDE5ci3P6UpMXC-bdZyiE3t8WFxLTLjNkk2kKF54e1dsvNXbGIcGIBo6pQdEgdt1uBSYgd_
BMP (图像文件格式(Bitmap))
//----图像处理-----BMP为DIB类型,从底向上显示---------
//阵列中的第一个字节表示位图左下角的象素,而最后一个字节表示位图右上角的象素。
http://blog.csdn.net/yang2011079080010/article/details/52528261
fopen()、fwrite()、fread()函数使用说明与示例
源码:
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
int Show(char *framebuffer_devices)
{
int fp = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
int screensize = 0;
char *fbp = 0;
int x = 0, y = 0;
int location = 0;
int bytes_per_pixel;// 组成每一个像素点的字节数
int count = 0;
FILE *file_fd = NULL;
file_fd = fopen("/bin/1.bmp", "r");
char buffer[3072054]; // 1280*800*3+54=
int readCnt = fread(buffer, sizeof(buffer), 1, file_fd); //返回值为0
printf("readCnt = %d\n", readCnt);
fclose(file_fd);
fp = open(framebuffer_devices, O_RDWR);
if(fp < 0)
{
printf("error: Can not open %s device!!!!!!!!!!!!!!!!!!!!!!!!!!\n", framebuffer_devices);
return -1;
}
if(ioctl(fp, FBIOGET_FSCREENINFO, &finfo))
{
printf("err FBIOGET_FSCREENINFO!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
close(fp);
return -2;
}
if(ioctl(fp, FBIOGET_VSCREENINFO, &vinfo))
{
printf("err FBIOGET_VSCREENINFO!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
close(fp);
return -3;
}
bytes_per_pixel = vinfo.bits_per_pixel / 8;
screensize = vinfo.xres * vinfo.yres * bytes_per_pixel;
printf("****wyb 2017/7/3 9:36 x = %d y = %d bytes_per_pixel = %d\n", vinfo.xres, vinfo.yres, bytes_per_pixel);
printf("screensize = %d\n", screensize);
fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fp, 0);
if((int) fbp == -1)
{
printf("err mmap!!!!!!!!!!!!!!!!!!!!!!!!!!");
close(fp);
return -4;
}
//for(count = 0; count <100; count ++)
for(count = 0; count >= 0; count ++)
{
printf("----- RED %d\n", count);
for(x = 0; x < vinfo.xres; x ++)
{
for(y = 0; y < vinfo.yres; y++)
{
location = x * bytes_per_pixel + y * finfo.line_length;
*(fbp + location + 0) = 0x00;// 蓝色的色深
*(fbp + location + 1) = 0x00;// 绿色的色深
*(fbp + location + 2) = 0xFF;// 红色的色深
//*(fbp + location + 3) = 0;// 是否透明
}
}
//usleep(500 * 1000);
sleep(1);
puts("----- GREEN");
for(x = 0; x < vinfo.xres; x ++)
{
for(y = 0; y < vinfo.yres; y++)
{
location = x * bytes_per_pixel + y * finfo.line_length;
*(fbp + location + 0) = 0x00;// 蓝色的色深
*(fbp + location + 1) = 0xFF;// 绿色的色深
*(fbp + location + 2) = 0x00;// 红色的色深
//*(fbp + location + 3) = 0;// 是否透明
}
}
//usleep(500 * 1000);
sleep(1);
puts("----- BLUE");
for(x = 0; x < vinfo.xres; x ++)
{
for(y = 0; y < vinfo.yres; y++)
{
location = x * bytes_per_pixel + y * finfo.line_length;
*(fbp + location + 0) = 0xFF;// 蓝色的色深
*(fbp + location + 1) = 0x00;// 绿色的色深
*(fbp + location + 2) = 0x00;// 红色的色深
//*(fbp + location + 3) = 0;// 是否透明
}
}
sleep(1);
for(x = 0; x < vinfo.xres; x ++)
{
for(y = 0; y < vinfo.yres; y++)
{
location = x * bytes_per_pixel + y * finfo.line_length;
// 2017/7/3 11:25 矫正BMP显示和LCD显示的上下反 799-y
*(fbp + location + 0) = buffer[54+(1280*(799-y)+x)*3+0];// 蓝色的色深
*(fbp + location + 1) = buffer[54+(1280*(799-y)+x)*3+1];// 绿色的色深
*(fbp + location + 2) = buffer[54+(1280*(799-y)+x)*3+2];// 红色的色深
//*(fbp + location + 3) = 0;// 是否透明
}
}
sleep(5);
}
munmap(fbp, screensize);
close(fp);
return 0;
}
int main(void)
{
char fb_path[30] = {0};
int i = 0;
system("echo on > /sys/power/state");
printf("fb0 begining \n");
Show("/dev/fb0");
#if 0
for(i = 0; i < 100; i ++)
{
memset(fb_path, 0, sizeof(fb_path));
sprintf(fb_path, "/dev/fb%d", i);
printf("show %s...\n", fb_path);
if(-1 == Show(fb_path))
break;
printf("%s ok\n\n", fb_path);
}
#endif
return 0;
}
- 通过全志R16平台TINAV2.1下的LCD显示BMP图片(分色排版)V1.0版本
- 在全志R16平台的tinav2.1系统下点亮客户的RGB屏幕V1.0(分色排版)
- 如何调整全志R16平台在tinav2.1下的频率V1.0(分色排版)
- 00关闭全志r16平台tinav2.5系统多余的DEBUG(分色排版)V1.0
- 全志R16平台的tinav2.1的系统和parrot v1.1的内核的合成(分色排版)V1.0
- 02全志R16平台tinav2.1系统下的开机自启动脚本的创建(分色排版)V1.1
- 新版本的全志R16平台的tinav2.1的系统打开softAP(分色排版)
- 全志R16平台的tinav2.1系统关闭adb_shell的步骤(分色排版)
- 全志R16平台的tinav2.0系统下调通HM1375(分色排版)
- 全志R16平台的parrotv1.1系统的编译手册(分色排版)V1.0
- 全志R16平台tinav2.1系统下调通rtl8188eu(分色排版)
- 全志R16平台的parrotv1.1的系统点亮OV5640(分色排版)版本V1.2
- 全志R16的android4.4.2平台点亮gc2145(evb30)版本:V1.1(分色排版)
- 全志R16平台配SPI的NOR FLASH的刷tinav2.1系统的解决过程(分色排版)
- 解决全志R16平台的新版本tinav2.1系统的PING自己的问题(分色排版)
- 旧版本版本的全志R16平台的tinav2.1的系统打开softAP(分色排版)
- 全志R16平台的android6.0.1系统下的RTL8188EU的配置V1.0(分色排版)
- 全志R16平台的android6.0.1系统下的RTL8188EU的配置(分色排版)V1.0
- js中的__proto__和prototype
- PAT甲级 1008. Elevator (20)
- 4.4以上BaseActivity 设置状态栏背景
- mysql数据库中java的long转成时间
- 集成百度地图定位时初学者遇到的一些小坑
- 通过全志R16平台TINAV2.1下的LCD显示BMP图片(分色排版)V1.0版本
- java的String类型的==和.equals()
- JAVA中的关键字及作用
- liferay7项目搭建
- leetcode 100. Same Tree
- TestNG参数化测试之Excel读取数据
- 软件工程课程设计问题总结——医院门诊系统(一):serverlet中alert不弹窗&弹窗乱码
- vscode插件离线安装方法
- MFC控制:实现打开PPT详细步骤