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

📄 main.c

📁 LZW compression example with java
💻 C
字号:
//This code demonstrated the cabilites of the LZW code and gif loader
//The GIF code and this demo requires Allegro to Compile and run
//The LZW code does not.
#include <stdio.h>
#include "allegro.h"
#include "lzw.h"
#include "gif.h"
int main(int argc, char *argv[])
{
LZW mytable;
BITMAP *btest;
PALETTE pal;
if (allegro_init())
   { allegro_message("Cannot Initialize Allegro.\n");
     return 1;
   }

if (install_keyboard())
   { allegro_message("Cannot Initialize Keyboard.\n");
     return 1;
   }

if(install_timer())
   { allegro_message("Cannot Initialize Timer \n.");
     return 1;
   }

if (install_mouse()<0)
   { allegro_message("Cannot Initialize Mouse.\n");
     return 1;
   }

//Set Graphics Mode
set_color_depth(16); //Make 256 Colours
if(set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,400,0,0))
  { allegro_message("Cannot Initialize Screen.\n");
    return 1;
   }
set_color_conversion(COLORCONV_TOTAL);
//Compress
create_lzw_table(&mytable,12);
//Here we create a compressed copy of sample
lzw_compress_file(&mytable,"test.txt","utest.txt");
//And we create an uncompressed copy for comparison
lzw_decompress_file(&mytable,"utest.txt", "untest.txt");

//Now we load a gif using our loader
//And display it
btest = load_gif("test.gif",pal);
select_palette(pal);
draw_sprite(screen, btest, 0,0);
destroy_bitmap(btest);
rest(2000);//Give the user time to see the image
return 0;
}
END_OF_MAIN()

⌨️ 快捷键说明

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