colormap.c
来自「Linux嵌入式设计配套光盘,学习嵌入式设计可参考」· C语言 代码 · 共 45 行
C
45 行
/*************************************************************************** * 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 + =
减小字号Ctrl + -
显示快捷键?