framebuffer如何显示argb?

qq_35442825 2018-06-22 10:12:34
我有一段内存中的argb数据,buffer, size, width, height。我如何通framebuffer显示在32位系统屏幕上。麻烦大家帮我写一下
...全文
318 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_35442825 2018-06-22
  • 打赏
  • 举报
回复
cv::Mat Jpeg2Mat(uint8_t *jpegData, uint64_t jpegSize)
{
auto res = decodeJpeg2X((uint8_t*)jpegData, jpegSize, "ARGB");
bool success = false;
std::vector<uint8_t> buff;
int width, height, size;
std::tie(success, buff, size, width, height) = res;//ARGB 数据的高,宽和buffer,size
}

这是我通过解码得到的argb数据
图形系统开发基础,我是转帖的,感觉不错,属于入门级别。 1:搭建Linux下的图形系统开发环境 图形输出在嵌入式开发中,多数是向FrameBuffer中写数据,然后会显示在LCD中,在Linux下做图形开发的时候,需要模拟各种环境,比如16位色的环境,32位色的环境等,这个时候需要在Linux中做一个配置的修改: [Copy to clipboard] [ - ]CODE: [root@localhost root]# vi /boot/grub/grub.conf 上面这条命令是用来编辑grub引导配置文件。该配置文件原来的内容为: [Copy to clipboard] [ - ]CODE: # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/sda2 # initrd /initrd-version.img #boot=/dev/sda default=0 timeout=10 splashimage=(hd0,0)/grub/splash.xpm.gz title Red Hat Linux (2.6.26) root (hd0,0) kernel /vmlinuz-2.6.26 initrd /initrd-2.6.26.img 将其修改为: [Copy to clipboard] [ - ]CODE: # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/sda2 # initrd /initrd-version.img #boot=/dev/sda default=0 timeout=10 splashimage=(hd0,0)/grub/splash.xpm.gz title Red Hat Linux (2.6.26) root (hd0,0) kernel /vmlinuz-2.6.26 vga=0x314 initrd /initrd-2.6.26.img 其实仅仅是在kernel /vmlinuz-2.6.26这一行末尾处加了一个vga=0x314,将Framebuffer设置为800x600x16的显示模式,其中800x600是屏幕分辨率,16表示显示的是16bit的彩色。下面详细的说一下关于vesa vga参数的含义: [Copy to clipboard] [ - ]CODE: 4bit 8bit 15bit 16bit 24bit 32bit 640x400 x 0x300 x x x x 640x480 x 0x301 0x310 0x311 0x312 x 800x600 0x302 0x303 0x313 0x314 0x315 x 1024x768 x 0x305 0x316 0x317 0x318 x 1280x1024 x 0x307 0x319 0x31A 0x31B x 1600x1200 x 0x31C 0x31D 0x31E 0x31F x 而在现在的开发环境中,和嵌入式平台中,用16bit的颜色的还是主流,所以,主要介绍一下16bit的颜色的类型,而颜色是由RGB组成: 常见16位颜色的类型分为: (1)565:依次排列为Red,Green,Blue,二进制表示为: [Copy to clipboard] [ - ]CODE: Red Green Blue RRRRR GGGGGG BBBBB (2)1555:依次排列为Alpha,Red,Green,Blue [Copy to clipboard] [ - ]CODE: Alpha Red Green Blue A RRRRR GGGGG BBBBB 565排列的颜色: 0xFFFF的颜色是白色,在RGB565中排列形式为: [Copy to clipboard] [ - ]CODE: R G B 11111 111111 111111 0xF800的颜色是红色,在RGB565中排列的形式为: [Copy to clipboard] [ - ]CODE: R G B 11111 000000 000000 0X7e0的颜色是绿色,在RGB565中排列的形式为: [Copy to clipboard] [ - ]CODE: R G B 00000 111111 000000 假设Alpha值为1的1555排列的颜色: 0XFC00的颜色是红色,在ARGB1555中排列形式为: [Copy to clipboard] [ - ]CODE: A R G B 1 11111 00000 00000 0X83E0的颜色是绿色,在ARGB1555中排列形式为: [Copy to clipboard] [ - ]CODE: A R G B 1 00000 11111 00000 其他颜色就不在这里一一赘述,需要在实践中慢慢累积与总结。 RGB简介 前面介绍了做了很多表来体现的就是RGB颜色排列形式,那么什么是RGB呢? 概述   RGB色彩模式是工业界的一种颜色标准,是通过对红(R)、绿(G)、蓝(B)三个颜色通道的变化以及它们相互之间的叠加来得到各式各样的颜色的,RGB即是代表红、绿、蓝三个通道的颜色,这个标准几乎包括了人类视力所能感知的所有颜色,是目前运用最广的颜色系统之一。   RGB色彩模式使用RGB模型为图像中每一个像素的RGB分量分配一个0~255范围内的强度值。例如:纯红色R值为255,G值为0,B值为0;灰色的R、G、B三个值相等(除了0和255);白色的R、G、B都为255;黑色的R、G、B都为0。RGB图像只使用三种颜色,就可以使它们按照不同的比例混合,在屏幕上重现16777216种颜色。   在 RGB 模式下,每种 RGB 成分都可使用从 0(黑色)到 255(白色)的值。 例如,亮红色使用 R 值 246、G 值 20 和 B 值 50。 当所有三种成分值相等时,产生灰色阴影。 当所有成分的值均为 255 时,结果是纯白色;当该值为 0 时,结果是纯黑色。    应用   目前的显示器大都是采用了RGB颜色标准,在显示器上,是通过电子枪打在屏幕的红、绿、蓝三色发光极上来产生色彩的,目前的电脑一般都能显示32位颜色,约有一百万种以上的颜色。   原理   RGB是从颜色发光的原理来设计定的,通俗点说它的颜色混合方式就好像有红、绿、蓝三盏灯,当它们的光相互叠合的时候,色彩相混,而亮度却等于两者亮度之总和(两盏灯的亮度嘛!),越混合亮度越高,即加法混合。   有色光可被无色光冲淡并变亮。如蓝色光与白光相遇,结果是产生更加明亮的浅蓝色光。知道它的混合原理后,在软件中设定颜色就容易理解了。    红、绿、蓝三盏灯的叠加情况,中心三色最亮的叠加区为白色,加法混合的特点:越叠加越明亮。   红、绿、蓝三个颜色通道每种色各分为255阶亮度,在0时“灯”最弱——是关掉的,而在255时“灯”最亮。当三色数值相同时为无色彩的灰度色,而三色都为255时为最亮的白色,都为0时为黑色。  RGB 颜色称为加成色,因为您通过将 R、G 和 B 添加在一起(即所有光线反射回眼睛)可产生白色。 加成色用于照明光、电视和计算机显示器。 例如,显示器通过红色、绿色和蓝色荧光粉发射光线产生颜色。绝大多数可视光谱都可表示为红、绿、蓝 (RGB) 三色光在不同比例和强度上的混合。 这些颜色若发生重叠,则产生青、洋红和黄。
开发板使用:CB-A(需要外接+5V) 1、在lichee中初始化RGB屏幕:KD027QVTPD022 W:\liuxing_csdn_tinav2.1\lichee\linux-3.4\drivers\video\sunxi\lcd\panels\default_panel.c static void LCD_panel_init(u32 sel) { u32 i; //printk("raoyiming +++ LCD_panel_init\n"); /**/ panel_rst(1); sunxi_lcd_delay_ms(1); panel_rst(0); sunxi_lcd_delay_ms(10); panel_rst(1); sunxi_lcd_delay_ms(120); return; } W:\liuxing_csdn_tinav2.1\lichee\linux-3.4\drivers\video\sunxi\lcd\panels\default_panel.h #define panel_rst(v) (sunxi_lcd_gpio_set_value(0, 0, v)) 第二个0是sys_config.fex中lcd_gpio_0 lcd_gpio_0 = port:PH07<1><0><0> 2、 W:\liuxing_csdn_tinav2.1\target\allwinner\astar-parrot\configs\sys_config.fex 生成的SPI的设备名: ;---------------------------------------------------------------------------------- ;[spi_board0] spi device configuration ;modalias = spi device name ;sflash_size = spi flash size, optional, if spi_board0 is nor flash , carefully ;max_speed_hz = max transfer speed ;bus_num = bus ID ;chip_select = chip select, 0,1 ;mode = SPI transfer mode ;---------------------------------------------------------------------------------- [spi_board0] ;modalias = "at25df641" modalias = "spidev" sflash_size = 32 max_speed_hz = 50000000 bus_num = 0 chip_select = 0 mode = 0 加入RGB的屏幕参数(如果希望调优请找模组厂协助): ;---------------------------------------------------------------------------------- ;lcd0 configuration ;lcd_if: 0:hv(sync+de); 1:8080; 2:ttl; 3:lvds; 4:dsi; 5:edp; 6:extend dsi ;lcd_x: lcd horizontal resolution ;lcd_y: lcd vertical resolution ;lcd_width: width of lcd in mm ;lcd_height: height of lcd in mm ;lcd_dclk_freq: in MHZ unit ;lcd_pwm_freq: in HZ unit ;lcd_pwm_pol: lcd backlight PWM polarity ;lcd_pwm_max_limit lcd backlight PWM max limit(<=255) ;lcd_hbp: hsync back porch ;lcd_ht: hsync total cycle ;lcd_vbp: vsync back porch ;lcd_vt: vysnc total cycle ;lcd_hspw: hsync plus width ;lcd_vspw: vysnc plus width ;lcd_lvds_if: 0:single link; 1:dual link ;lcd_lvds_colordepth: 0:8bit; 1:6bit ;lcd_lvds_mode: 0:NS mode; 1:JEIDA mode ;lcd_frm: 0:disable; 1:enable rgb666 dither; 2:enable rgb656 dither ;lcd_io_phase: 0:noraml; 1:intert phase(0~3bit: vsync phase; 4~7bit:hsync phase; ; 8~11bit:dclk phase; 12~15bit:de phase) ;lcd_gamma_en lcd gamma correction enable ;lcd_bright_curve_en lcd bright curve correction enable ;lcd_cmap_en lcd color map function enable ;deu_mode 0:smoll lcd screen; 1:large lcd screen(larger than 10inch) ;lcdgamma4iep: Smart Backlight parameter, lcd gamma vale * 10; ; decrease it while lcd is not bright enough; increase while lcd is too bright ;smart_color 90:normal lcd screen 65:retina lcd screen(9.7inch) ;---------------------------------------------------------------------------------- [lcd0_para] lcd_used = 1 lcd_driver_name = "default_lcd" lcd_if = 0 lcd_x = 320 lcd_y = 240 lcd_width = 0 lcd_height = 0 lcd_dclk_freq = 5 lcd_pwm_used = 1 lcd_pwm_ch = 0 lcd_pwm_freq = 50000 lcd_pwm_pol = 1 lcd_hbp = 60 lcd_ht = 390 lcd_hspw = 6 lcd_vbp = 6 lcd_vt = 250 lcd_vspw = 2 lcd_lvds_if = 0 lcd_lvds_colordepth = 0 lcd_lvds_mode = 0 lcd_frm = 1 lcd_gamma_en = 0 lcd_bright_curve_en = 0 lcd_cmap_en = 0 deu_mode = 0 lcdgamma4iep = 22 smart_color = 90 lcd_bl_en = port:PD13<1><0><1> lcd_power = "axp22_dc1sw" lcd_gpio_0 = port:PH07<1><0><0> lcd_gpio_1 = port:PL04<1><0><0> lcd_gpio_2 = port:PL11<1><0><1> ;lcdd0 = port:PD00<2><0><2> ;lcdd1 = port:PD01<2><0><2> lcdd2 = port:PD02<2><0><2> lcdd3 = port:PD03<2><0><2> lcdd4 = port:PD04<2><0><2> lcdd5 = port:PD05<2><0><2> lcdd6 = port:PD06<2><0><2> lcdd7 = port:PD07<2><0><2> ;lcdd8 = port:PD08<2><0><2> ;lcdd9 = port:PD09<2><0><2> lcdd10 = port:PD10<2><0><2> lcdd11 = port:PD11<2><0><2> lcdd12 = port:PD12<2><0><2> lcdd13 = port:PD13<2><0><2> lcdd14 = port:PD14<2><0><2> lcdd15 = port:PD15<2><0><2> ;lcdd16 = port:PD16<2><0><2> ;lcdd17 = port:PD17<2><0><2> lcdd18 = port:PD18<2><0><2> lcdd19 = port:PD19<2><0><2> lcdd20 = port:PD20<2><0><2> lcdd21 = port:PD21<2><0><2> lcdd22 = port:PD22<2><0><2> lcdd23 = port:PD23<2><0><2> lcdclk = port:PD24<2><0><3> lcdde = port:PD25<2><0><2> lcdhsync = port:PD26<2><0><2> lcdvsync = port:PD27<2><0><2> 3、原理:生成设备节点:/dev/spidev0.0。然后通用C格式的应用程序访问这个设备节点来初始化LCD。 编译刷机之后: 开机之后背光是亮的(背光被强制拉高了) root@TinaLinux:/# root@TinaLinux:/# find . -name spi* ./bin/spidev_test0 ./dev/spidev0.0 ./proc/irq/97/spi0 ./rom/bin/spidev_test0 ./rom/usr/lib/opkg/info/spidev_test0.control ./rom/usr/lib/opkg/info/spidev_test0.list ./sys/bus/spi ./sys/bus/spi/devices/spi0.0 ./sys/bus/spi/drivers/spidev ./sys/bus/spi/drivers/spidev/spi0.0 ./sys/bus/platform/devices/spi.0 ./sys/bus/platform/drivers/spi ./sys/bus/platform/drivers/spi/spi.0 ./sys/devices/platform/spi.0 ./sys/devices/platform/spi.0/spi_master ./sys/devices/platform/spi.0/spi_master/spi0 ./sys/devices/platform/spi.0/spi_master/spi0/spi0.0 ./sys/devices/platform/spi.0/spi_master/spi0/spi0.0/spidev ./sys/devices/platform/spi.0/spi_master/spi0/spi0.0/spidev/spidev0.0 ./sys/class/spi_master ./sys/class/spi_master/spi0 ./sys/class/spidev ./sys/class/spidev/spidev0.0 ./sys/kernel/debug/clk/hosc/pll_periph/pll_periphahb1/ahb1/spinlock ./sys/kernel/debug/clk/hosc/pll_periph/spi0 ./sys/kernel/debug/clk/hosc/spi1 ./sys/module/spidev ./usr/lib/opkg/info/spidev_test0.control ./usr/lib/opkg/info/spidev_test0.list root@TinaLinux:/# root@TinaLinux:/# (初始化屏幕之后是全绿:) root@TinaLinux:/# spidev_test0 spi mode: 0 bits per word: 8 max speed: 500000 Hz (500 KHz) send spi message success! root@TinaLinux:/# root@TinaLinux:/# (红绿蓝单色和一张静态图片的切换) root@TinaLinux:/# root@TinaLinux:/# root@TinaLinux:/# cb_test [ 203.906264] request_suspend_state: wakeup (0->0) at 203906241807 (1970-01-01 08:41:09.853073511 UTC) fb0 begining readCnt = 1 ****wyb 2017/7/3 9:36 x = 320 y = 240 bytes_per_pixel = 4 screensize = 307200 ----- RED 0 ----- GREEN ----- BLUE ----- RED 1 ----- GREEN ----- BLUE ^C root@TinaLinux:/# (绿红黑等单色循环测试) root@TinaLinux:/# root@TinaLinux:/# root@TinaLinux:/# fbtest **** wyb fbtest.c-391-main argc=1 **** wyb fbtest.c-453-main argc2=1 **** wyb fbtest.c-462-main opening framebuffer device success! **** wyb fbtest.c-471-main getting fix screeninfo success! **** wyb fbtest.c-480-main getting var screeninfo success! **** wyb fbtest.c-489-main setting mode success! **** wyb fbtest.c-498-main mmap'ing framebuffer device success! testing: ARGB for sizes: 320x240 ^C root@TinaLinux:/# root@TinaLinux:/# 4、改进方向: W:\liuxing_csdn_tinav2.1\lichee\linux-3.4\drivers\video\sunxi\lcd\panels\default_panel.c 在驱动中增加SPI初始化部分,然后还可以让开机自动进入红绿蓝的测试程序!

23,116

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧