File: allegtest.c

package info (click to toggle)
devil 1.6.7-5%2Betch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 11,536 kB
  • ctags: 7,441
  • sloc: ansic: 35,573; sh: 8,075; cpp: 7,465; pascal: 792; makefile: 399; python: 47
file content (51 lines) | stat: -rw-r--r-- 975 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Almost identical to Allegro's ex15.c

#include <il/il.h>
#include <il/ilu.h>
#include <il/ilut.h>
#include <allegro.h>
#include <stdlib.h>
#include <stdio.h>


int main(int argc, char *argv[])
{
  BITMAP *Image;
  PALETTE Pal;
  ILuint Id;

  if (argc != 2) {
     printf("Please specify a filename.\n");
     return 1;
  }

  ilStartup();
  ilGenImages(1, &Id);
  ilBindImage(Id);
  ilLoadImage(argv[1]);

//  if (ilGetInteger(IL_IMAGE_FORMAT) == GL_BGR ||
//      ilGetInteger(IL_IMAGE_FORMAT) == GL_BGRA)
        ilSwapColours();

  Image = (BITMAP*)ilutConvertToAlleg(Pal);

  allegro_init();
  install_keyboard();
  if (ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL) == 8) {
     set_color_depth(8);
     set_palette(Pal);
  }
  else
     set_color_depth(32);
  set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);

  blit(Image, screen, 0, 0, (SCREEN_W - Image->w) / 2,
        (SCREEN_H - Image->h) / 2, Image->w, Image->h);

  destroy_bitmap(Image);

  readkey();

  return 0;
}