File: iio.c

package info (click to toggle)
allegro5 2%3A5.0.10-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 14,856 kB
  • ctags: 15,948
  • sloc: ansic: 87,540; cpp: 9,693; objc: 3,491; python: 2,057; sh: 829; makefile: 93; perl: 37; pascal: 24
file content (127 lines) | stat: -rw-r--r-- 4,160 bytes parent folder | download
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include "allegro5/allegro.h"
#include "allegro5/allegro_image.h"
#include "allegro5/internal/aintern_exitfunc.h"
#include "allegro5/internal/aintern_image.h"
#include "allegro5/internal/aintern_image_cfg.h"


/* globals */
static bool iio_inited = false;


/* Function: al_init_image_addon
 */
bool al_init_image_addon(void)
{
   int success;

   if (iio_inited)
      return true;

   success = 0;

   success |= al_register_bitmap_loader(".pcx", _al_load_pcx);
   success |= al_register_bitmap_saver(".pcx", _al_save_pcx);
   success |= al_register_bitmap_loader_f(".pcx", _al_load_pcx_f);
   success |= al_register_bitmap_saver_f(".pcx", _al_save_pcx_f);

   success |= al_register_bitmap_loader(".bmp", _al_load_bmp);
   success |= al_register_bitmap_saver(".bmp", _al_save_bmp);
   success |= al_register_bitmap_loader_f(".bmp", _al_load_bmp_f);
   success |= al_register_bitmap_saver_f(".bmp", _al_save_bmp_f);

   success |= al_register_bitmap_loader(".tga", _al_load_tga);
   success |= al_register_bitmap_saver(".tga", _al_save_tga);
   success |= al_register_bitmap_loader_f(".tga", _al_load_tga_f);
   success |= al_register_bitmap_saver_f(".tga", _al_save_tga_f);

/* ALLEGRO_CFG_IIO_HAVE_* is sufficient to know that the library
   should be used. i.e., ALLEGRO_CFG_IIO_HAVE_GDIPLUS and
   ALLEGRO_CFG_IIO_HAVE_PNG will never both be set. */

#ifdef ALLEGRO_CFG_IIO_HAVE_GDIPLUS
   {
      char const *extensions[] = {".tif", ".tiff", ".jpg", ".jpeg", ".gif",
         ".png", NULL};
      int i;

      if (_al_init_gdiplus()) {
         for (i = 0; extensions[i]; i++) {
            success |= al_register_bitmap_loader(extensions[i], _al_load_gdiplus_bitmap);
            success |= al_register_bitmap_loader_f(extensions[i], _al_load_gdiplus_bitmap_f);
            success |= al_register_bitmap_saver(extensions[i], _al_save_gdiplus_bitmap);
         }

	     success |= al_register_bitmap_saver_f(".tif", _al_save_gdiplus_tif_f);
	     success |= al_register_bitmap_saver_f(".tiff", _al_save_gdiplus_tif_f);
         success |= al_register_bitmap_saver_f(".gif", _al_save_gdiplus_gif_f);
	     success |= al_register_bitmap_saver_f(".png", _al_save_gdiplus_png_f);
	     success |= al_register_bitmap_saver_f(".jpg", _al_save_gdiplus_jpg_f);
	     success |= al_register_bitmap_saver_f(".jpeg", _al_save_gdiplus_jpg_f);	  
      }
   }
#endif

#ifdef ALLEGRO_CFG_IIO_HAVE_PNG
   success |= al_register_bitmap_loader(".png", _al_load_png);
   success |= al_register_bitmap_saver(".png", _al_save_png);
   success |= al_register_bitmap_loader_f(".png", _al_load_png_f);
   success |= al_register_bitmap_saver_f(".png", _al_save_png_f);
#endif

#ifdef ALLEGRO_CFG_IIO_HAVE_JPG
   success |= al_register_bitmap_loader(".jpg", _al_load_jpg);
   success |= al_register_bitmap_saver(".jpg", _al_save_jpg);
   success |= al_register_bitmap_loader_f(".jpg", _al_load_jpg_f);
   success |= al_register_bitmap_saver_f(".jpg", _al_save_jpg_f);

   success |= al_register_bitmap_loader(".jpeg", _al_load_jpg);
   success |= al_register_bitmap_saver(".jpeg", _al_save_jpg);
   success |= al_register_bitmap_loader_f(".jpeg", _al_load_jpg_f);
   success |= al_register_bitmap_saver_f(".jpeg", _al_save_jpg_f);
#endif

#ifdef ALLEGRO_CFG_WANT_NATIVE_IMAGE_LOADER
#ifdef ALLEGRO_IPHONE
   {
      char const *extensions[] = {".tif", ".tiff", ".jpg", ".jpeg", ".gif",
         ".png", ".BMPf", ".ico", ".cur", ".xbm", NULL};
      int i;
      for (i = 0; extensions[i]; i++) {
         success |= al_register_bitmap_loader(extensions[i], _al_iphone_load_image);
         success |= al_register_bitmap_loader_f(extensions[i], _al_iphone_load_image_f);
      }
   }
#endif

#ifdef ALLEGRO_MACOSX
   success |= _al_osx_register_image_loader();
#endif
#endif

   if (success)
      iio_inited = true;

   _al_add_exit_func(al_shutdown_image_addon, "al_shutdown_image_addon");

   return success;
}


/* Function: al_shutdown_image_addon
 */
void al_shutdown_image_addon(void)
{
   iio_inited = false;
}


/* Function: al_get_allegro_image_version
 */
uint32_t al_get_allegro_image_version(void)
{
   return ALLEGRO_VERSION_INT;
}


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