⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.c

📁 gif编码和解码的程序。:)
💻 C
字号:
// GIF loader/saver test program
// By Paul Bartrum

#include <stdio.h>
#include "load_gif.c"
#include "save_gif.c"

void main()
{
	BITMAP *bmp;
	PALETTE pal;

	// init allegro
	allegro_init();
	install_keyboard();

	// tell allegro of the gif routines
	register_bitmap_file_type("GIF", load_gif, save_gif);

	printf("Loading image test.pcx\n");

	// load test image
	bmp = load_bitmap("test.pcx", pal);
	if(bmp == NULL) {
		printf("Couldn't load image test.pcx\n");
		exit(0);
	}

	printf("Saving test.pcx as a gif (test.gif)\n");

	// save as a gif
	save_bitmap("test.gif", bmp, pal);

	printf("Loading test.gif\n");

	// load the gif
	bmp = load_bitmap("test.gif", pal);
	if(bmp == NULL) {
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);		// must be in text mode to use printf()
		printf("Couldn't load test.gif\n");
		exit(0);
	}

	printf("Press a key to display...\n");

	// wait for keypress
	readkey();

	// set the display
	set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0);

	// set the correct palette
	set_palette(pal);

	// copy the bitmap just loaded onto the screen
	blit(bmp, screen, 0, 0, 0, 0, bmp->w, bmp->h);

	// output text "Press a key to continue"
	textout(screen, font, "Press a",  220,  80, makecol(0, 0, 0));
	textout(screen, font, "key to",   220, 100, makecol(0, 0, 0));
	textout(screen, font, "continue", 220, 120, makecol(0, 0, 0));

	// wait for keypress
	readkey();

	// shut everything down
	destroy_bitmap(bmp);

	// that's it!
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -