示例#1
0
int main(int argc, char * argv[]) {

    struct Surface * sur;
    sur = open_fb("/dev/fb0");

    if (!sur) {
        return 1;
    }

    show_bmp("background.bmp", sur);

    sur->destroy(sur);
    return 0;

}
static int fbsplash_load() {
	fb_fd = -1;
	last_pos = 0;

	/* Kick start our TTF library */
	if (TTF_Init() < 0) {
		printk("Couldn't initialise TTF.\n");
	}

	/* Find out the FB size */
	if (get_fb_settings(0)) {
		printk("Couldn't get fb settings.\n");
		return 1;
	}

	arg_vc = get_active_vt();
	arg_mode = 's';

	/* Read theme config file */
	if (arg_theme == NULL)
		arg_theme = DEFAULT_THEME;
	config_file = get_cfg_file(arg_theme);
	if (!config_file) {
		printk("Couldn't load config file %s.\n", arg_theme);
		return 1;
	} else
		printk("Using configuration file %s.\n", config_file);

	parse_cfg(config_file);

	/* Prime the font cache with glyphs so we don't need to allocate them later */
	TTF_PrimeCache("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -.", global_font, TTF_STYLE_NORMAL);

	boot_message = rendermessage;

	fb_fd = open_fb();
	if (fb_fd == -1) {
		printk("Couldn't open framebuffer device.\n");
		return 1;
	}

	if (fb_fix.visual == FB_VISUAL_DIRECTCOLOR)
		set_directcolor_cmap(fb_fd);

	fbsplash_fd = open(SPLASH_DEV, O_WRONLY); /* Don't worry if it fails */

	do_getpic(FB_SPLASH_IO_ORIG_USER, 1, 'v'); /* Don't worry if it fails */
	if (do_getpic(FB_SPLASH_IO_ORIG_USER, 0, 's') == -1)
		no_silent_image = 1; /* We do care if this fails. */

	/* These next two touch the kernel and are needed even for silent mode, to
	 * get the colours right (even on 32-bit depth displays funnily enough. */
	do_config(FB_SPLASH_IO_ORIG_USER);
	cmd_setstate(1, FB_SPLASH_IO_ORIG_USER);

	/* copy the silent pic to base_image for safe keeping */
	if (!no_silent_image) {
		base_image_size = silent_img.width * silent_img.height * (silent_img.depth >> 3);
		base_image = malloc(base_image_size);
		if (!base_image) {
			printk("Couldn't get enough memory for framebuffer image.\n");
			return 1;
		}
		memcpy(base_image, (void*)silent_img.data, base_image_size);
	}