浅析minigui在InitGAL中fbcon显示模式下FB_SavePalette调色板设置
#define saved_cmaplen (this->hidden->saved_cmaplen)
#define saved_cmap (this->hidden->saved_cmap)
static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo,
struct fb_var_screeninfo *vinfo)
{
int i;
/* Save hardware palette, if needed */
if ( finfo->visual == FB_VISUAL_PSEUDOCOLOR ) {
// 伪彩,那么有palette调色板
// 保存到this->hidden->saved_cmap
saved_cmaplen = 1<bits_per_pixel; // 一共有1<<16=64K个像素点
// 每个像素点由RGB共3种色值组成,每种色值占据2个字节
// 所以需要3*saved_cmaplen*2
// 存放R值 saved_cmap[0] ~ saved_cmap[saved_cmaplen-1]
// 存放B值 saved_cmap[saved_cmaplen] ~ saved_cmap[2*saved_cmaplen-1]
// 存放G值 saved_cmap[2*saved_cmaplen] ~ saved_cmap[3*saved_cmaplen-1]
saved_cmap=(__u16 *)malloc(3*saved_cmaplen*sizeof(*saved_cmap));
if ( saved_cmap != NULL ) {
FB_SavePaletteTo(this, saved_cmaplen, saved_cmap);
}
}
/* Added support for FB_VISUAL_DIRECTCOLOR.
With this mode pixel information is passed through the palette...
Neat fading and gamma correction effects can be had by simply
fooling around with the palette instead of changing the pixel
values themselves... Very neat!
Adam Meyerowitz 1/19/2000
ameyerow@optonline.com
*/
if ( finfo->visual == FB_VISUAL_DIRECTCOLOR ) {
__u16 new_entries[3*256];
// minigui可输入色值为256色,minigui不用作任何改动
// 至于0-255这些色值在kernel驱动中被重新映射到了什么颜色
// minigui不用去关心,对于一个新的lcd屏幕,可能色值索引存在该lcd屏幕自己的
// 定义,不是按0-255依次对应颜色的,那么这时minigui不用作调整,
// 只需调整kernel驱动中的重映射表就可以完美显示
// minigui中的所有256色图片[luther.gliethttp]
/* Save the colormap */
saved_cmaplen = 256;
saved_cmap=(__u16 *)malloc(3*saved_cmaplen*sizeof(*saved_cmap));
if ( saved_cmap != NULL ) {
FB_SavePaletteTo(this, saved_cmaplen, saved_cmap); // 先保存原有palette数据[luther.gliethttp]
}
/* Allocate new identity colormap */
for ( i=0; i<256; ++i ) {
new_entries[(0*256)+i] =
new_entries[(1*256)+i] =
new_entries[(2*256)+i] = (i<<8)|i;
}
FB_RestorePaletteFrom(this, 256, new_entries); // 设置成自己定义的palette数据
}
}
void FB_SavePaletteTo(_THIS, int palette_len, __u16 *area)
{
struct fb_cmap cmap;
cmap.start = 0;
cmap.len = palette_len;
cmap.red = &area[0*palette_len]; // red存储地址
cmap.green = &area[1*palette_len]; // green存储地址
cmap.blue = &area[2*palette_len]; // blue存储地址
cmap.transp = NULL; // 不获取透明色[luther.gliethttp]
ioctl(console_fd, FBIOGETCMAP, &cmap); // 从kernel驱动获取该lcd驱动对应的palette[luther.gliethttp]
}
阅读(2271) | 评论(0) | 转发(0) |