📄 colormap.c
字号:
/*************************************************************************** * colormap.c * * Provide utilities for manipulating framebuffer colormaps. * * See <kernel-source-dir>/include/linux/fb.h for framebuffer data * structures. ***************************************************************************/#include <asm/types.h>#include <stdlib.h>#include "colormap.h"struct fb_cmap *new_fb_cmap(int ncolors){ __u8 *temp_array; struct fb_cmap *cmap; /* Allocate memory for the cmap structure and the color arrays. */ temp_array = (__u8 *)malloc(sizeof(struct fb_cmap) + 4*ncolors*sizeof(__u16)); if(!temp_array){ return NULL; }else{ /* Fill in the colormap structure using the new memory. */ cmap = (struct fb_cmap *)&temp_array[0]; cmap->start = 0; cmap->len = ncolors; cmap->red = (__u16 *)&temp_array[sizeof(struct fb_cmap)]; cmap->green = &cmap->red[ncolors]; cmap->blue = &cmap->red[2*ncolors]; cmap->transp = &cmap->red[3*ncolors]; return cmap; }}void free_fb_cmap(struct fb_cmap *cmap){ /* Since the cmap structure was the first item in the allocated memory, we * can use its address for the free call. */ free((void *)cmap);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -