Code Search for Developers
 
 
  

exbitmap.c from Allegro game programming library at Krugle


Show exbitmap.c syntax highlighted

/*
 *    Example program for the Allegro library, by Shawn Hargreaves.
 *
 *    This program demonstrates how to load and display a bitmap file.
 */


#include "allegro.h"



int main(int argc, char *argv[])
{
   AL_BITMAP *the_image;
   AL_PALETTE the_palette;

   allegro_init();

   if (argc != 2) {
      al_show_message("Usage: 'exbitmap filename.[bmp|lbm|pcx|tga]'\n");
      return 1;
   }

   al_install_keyboard(); 
   if (al_set_gfx_mode(AL_GFX_SAFE, 320, 200, 0, 0) != 0) {
      al_set_gfx_mode(AL_GFX_NONE, 0, 0, 0, 0);
      al_show_message("Unable to set any graphic mode\n%s\n", al_error);
      return 1;
   }

   /* read in the bitmap file */
   the_image = al_load_bitmap(argv[1], the_palette);
   if (!the_image) {
      al_set_gfx_mode(AL_GFX_NONE, 0, 0, 0, 0);
      al_show_message("Error reading bitmap file '%s'\n", argv[1]);
      return 1;
   }

   /* select the bitmap palette */
   al_set_palette(the_palette);

   /* al_blit the image onto the al_screen */
   al_blit(the_image, al_screen, 0, 0, (AL_SCREEN_W-the_image->w)/2, (AL_SCREEN_H-the_image->h)/2, the_image->w, the_image->h);

   /* destroy the bitmap */
   al_destroy_bitmap(the_image);

   al_read_key();
   return 0;
}

AL_END_OF_MAIN();




See more files for this project here

Allegro game programming library

Allegro is a cross-platform library intended for use in computer games and other types of multimedia programming.

Project homepage: http://sourceforge.net/projects/alleg
Programming language(s): Assembly,C,Shell Script
License: other

  allegro.pcx
  ex12bit.c
  ex3buf.c
  ex3d.c
  exaccel.c
  exalpha.c
  example.dat
  example.h
  examples.txt
  exbitmap.c
  exblend.c
  excamera.c
  excolmap.c
  excustom.c
  exdata.c
  exdbuf.c
  exdodgy.c
  exexedat.c
  exfixed.c
  exflame.c
  exflip.c
  exgui.c
  exhello.c
  exjoy.c
  exkeys.c
  exlights.c
  exmem.c
  exmidi.c
  exmouse.c
  expal.c
  expat.c
  exquat.c
  exrgbhsv.c
  exsample.c
  exscale.c
  exscn3d.c
  exscroll.c
  exshade.c
  exspline.c
  exsprite.c
  exstars.c
  exstream.c
  exswitch.c
  extimer.c
  extrans.c
  extruec.c
  exunicod.c
  exupdate.c
  exxfade.c
  exzbuf.c
  mysha.pcx
  planet.pcx
  running.dat
  running.h
  unifont.dat