Color Map 剖析

本文详细解析了Framebuffer设备驱动结构及ColorMap应用,包括非标准驱动的使用,structfb_cmap结构的剖析,以及如何在anakinfb.c驱动程序中实现颜色映射表的操作。通过实例分析,读者可以轻松掌握Framebuffer驱动编写技巧。

Framebuffer驱动程序模型
  下图会向你展示目前的framebuffer设备驱动的结构,最常用的是非标准驱动。很明显他所处的层次最高,程序编写是最容易的。理解了这个图的,你已经很轻松的去完成一个fb驱动,比如给sa1100,s2410,s2440系列的ARM的LCD控制器写驱动。
 

Color Map 剖析
在framebuffer驱动程序设计中,cmap这个东东太晕了。现在我要把他赤裸裸的剖析给大家:)
1. struct fb_cmap
 
/*颜色映射表*/
struct fb_cmap {
       __u32 start;                  /* First entry   */
       __u32 len;                    /* Number of entries */
       __u16 *red;                  /* 红色   */
       __u16 *green;               /*绿色*/
       __u16 *blue;                 /*蓝色*/
       __u16 *transp;                     /* 透明度,允许 NULL */
};
该结构在fb.h文件中定义,在struct fb_ops结构中有两个成员函数与其相关:
    /*获取颜色表*/
    int (*fb_get_cmap)(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info);
    /*设定颜色表*/
    int (*fb_set_cmap)(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info);
在struct fb_info结构中有变量:
  struct fb_cmap cmap;                 /* Current cmap */
在fpgen基础操作下提供:
extern int fbgen_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info);
extern int fbgen_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info);

在文件/* drivers/video/fbcmap.c */中提供更多的cmap应用
extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp);
extern void fb_copy_cmap(struct fb_cmap *from, struct fb_cmap *to, int fsfromto);
extern int fb_get_cmap(struct fb_cmap *cmap, int kspc,
int (*getcolreg)(u_int, u_int *, u_int *, u_int *,u_int *, struct fb_info *),
                                struct fb_info *fb_info);
extern int fb_set_cmap(struct fb_cmap *cmap, int kspc,
                              int (*setcolreg)(u_int, u_int, u_int, u_int, u_int,struct fb_info *),
                              struct fb_info *fb_info);
extern struct fb_cmap *fb_default_cmap(int len);
extern void fb_invert_cmaps(void);

2. 通过文件解析
在anakinfb.c文件中,cmap如图
 
 
在stifb.c

本文介绍的设备是位于/video目录下面的anakinfb.c驱动程序。虽然我不清楚那个设备的特性,但是从对程序的分析中我们仍然知道如何编写一个frame buffer设备驱动。

    本文是个标准的fb驱动。共221行,包含函数如下: 

  1. static int  anakinfb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue, u_int *transp, struct fb_info *info) 31行
  2. static int anakinfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,u_int transp, struct fb_info *info) 45行
  3. static int anakinfb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info) 57行
  4. static int anakinfb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) 75行
  5. static int anakinfb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) 111行
  6. static int anakinfb_get_cmap(struct fb_cmap *cmap, int kspc, int con,     struct fb_info *info) 117行
  7. static int anakinfb_set_cmap(struct fb_cmap *cmap, int kspc, int con,     struct fb_info *info) 130行
  8. static int anakinfb_switch_con(int con, struct fb_info *info) 147行
  9. static int anakinfb_updatevar(int con, struct fb_info *info) 155行
  10. static void anakinfb_blank(int blank, struct fb_info *info) 161行
  11.  int __init anakinfb_init(void) 178行

函数1,2是寄存器操作用。函数3,4,5,6,7是fb_ops函数。函数8用于切换控制台。函数9用于更新变量。函数10用于闪烁屏幕。函数11用于初始化设备。
    很奇怪,对fb设备的读写函数怎么没有!值得说明的是open,release,read,write,ioctl,mmap等函数的实现是由fbmem.c文件实现了。也就是说所有的fb设备在给定了fb_info后,所有的操作都是一样的。在明确的fb_info前提下,fbmem.c中的函数可以工作的很好。这样大家应该感到非常轻松了吧,只要完成上述的几个设备相关的函数,frame buffer设备的驱动就写完了:) 
    系统的结构如图: 
 

====

http://www.dzjs.net/html/qianrushixitong/2007/0429/2025_3.html

### Tecplot 颜色映射教程与使用 Tecplot 是一款广泛应用于工程仿真数据可视化分析的强大工具,在处理流体动力学、热传导以及其他物理现象的数据时尤为出色。对于颜色映射功能而言,该软件提供了丰富的选项来帮助用户更好地理解和展示复杂的数据集。 #### 创建自定义颜色表 为了实现更直观的结果呈现,可以创建并应用自定义的颜色方案: 1. 打开 `Plot` 菜单下的 `Color Maps...` 对话框; 2. 在弹出窗口中点击 `New Color Map` 来新建一个调色板; 3. 设置所需参数如范围最小值最大值以及中间过渡色彩等[^1]; ```python # Python script example to set up colormap programmatically within Tecplot import tecplot as tp from tecplot.constant import * dataset = tp.active_frame().dataset colormap = dataset.colormaps[0] # Define custom colors for the colormap custom_colors = [ (0, 'blue'), (.5, 'white'), (1, 'red') ] for position, color in custom_colors: colormap.add_color(position=position, rgb=color) ``` #### 应用预设样式库中的配色方案 除了手动调整外,还可以直接选用内置的一些经典风格来进行快速设置。这些预先配置好的模板能够满足大多数情况下对于美观性和科学性的双重要求。 - 访问 `File -> Load Add-on -> Apply Palette` 导入官方提供的多种主题包之一; - 或者通过在线资源获取更多第三方贡献的设计模式,并按照说明文档完成安装过程。 #### 数据过滤器的应用 当面对多变量共存的局面下,合理利用过滤机制有助于突出显示特定区间内的变化趋势而不至于造成视觉混乱。这一步骤同样可以在上述提到过的 “Color Maps” 界面里轻松达成目标——只需勾选相应条件即可生效。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值