File: ex_nodisplay.c

package info (click to toggle)
allegro5 2%3A5.2.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,820 kB
  • sloc: ansic: 109,795; cpp: 12,976; objc: 4,592; java: 2,845; python: 2,595; javascript: 1,238; sh: 1,008; makefile: 40; xml: 27; pascal: 24
file content (70 lines) | stat: -rw-r--r-- 1,634 bytes parent folder | download | duplicates (5)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* Test that bitmap manipulation without a display works. */

#include <stdio.h>
#include "allegro5/allegro.h"
#include "allegro5/allegro_image.h"

#include "common.c"

int main(int argc, char **argv)
{
   ALLEGRO_BITMAP *bmp;
   ALLEGRO_BITMAP *sprite;
   ALLEGRO_COLOR c1, c2, c3;
   bool rc;

   (void)argc;
   (void)argv;

   if (!al_init()) {
      abort_example("Error initialising Allegro\n");
   }
   al_init_image_addon();
   init_platform_specific();

   sprite = al_load_bitmap("data/cursor.tga");
   if (!sprite) {
      abort_example("Error loading data/cursor.tga\n");
   }

   bmp = al_create_bitmap(256, 256);
   if (!bmp) {
      abort_example("Error creating bitmap\n");
   }

   al_set_target_bitmap(bmp);

   c1 = al_map_rgb(255, 0, 0);
   c2 = al_map_rgb(0, 255, 0);
   c3 = al_map_rgb(0, 255, 255);

   al_clear_to_color(al_map_rgba(255, 0, 0, 128));
   al_draw_bitmap(sprite, 0, 0, 0);
   al_draw_tinted_bitmap(sprite, c1, 64, 0, ALLEGRO_FLIP_HORIZONTAL);
   al_draw_tinted_bitmap(sprite, c2, 0, 64, ALLEGRO_FLIP_VERTICAL);
   al_draw_tinted_bitmap(sprite, c3, 64, 64, ALLEGRO_FLIP_HORIZONTAL |
      ALLEGRO_FLIP_VERTICAL);

   al_set_target_bitmap(NULL);

   rc = al_save_bitmap("ex_nodisplay_out.tga", bmp);

   if (rc) {
#ifdef ALLEGRO_POPUP_EXAMPLES
      al_show_native_message_box(NULL, "ex_nodisplay_out", "",
         "Saved ex_nodisplay_out.tga", NULL, 0);
#else
      printf("Saved ex_nodisplay_out.tga\n");
#endif
   }
   else {
      abort_example("Error saving ex_nodisplay_out.tga\n");
   }

   al_destroy_bitmap(sprite);
   al_destroy_bitmap(bmp);

   return 0;
}

/* vim: set sts=3 sw=3 et: */