image.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /** Simple macro wrappers around al_bitmap_xxx */
  2. #ifndef ERUTA_IMAGE_H
  3. #define ERUTA_IMAGE_H
  4. #include <allegro5/allegro.h>
  5. #include <allegro5/allegro_font.h>
  6. /** An image type. Useful as a shorthand to Allegro's long names. */
  7. typedef ALLEGRO_BITMAP Image;
  8. /** A color type. Useful as a shorthand to Allegro's long names. */
  9. typedef ALLEGRO_COLOR Color;
  10. /** A font type. Useful as a shorthand to Allegro's long names. */
  11. typedef ALLEGRO_FONT Font;
  12. /** Some utility macros, that wrap around allegro functions.
  13. * Useful as shorthand for Allegro's long names.
  14. */
  15. #define image_w(IMAGE) al_get_bitmap_width(IMAGE)
  16. #define image_h(IMAGE) al_get_bitmap_height(IMAGE)
  17. #define image_load(FILENAME) al_load_bitmap(FILENAME)
  18. #define image_drawscale(BMP, SX, SY, SW, SH, DX, DY, DW, DH, FLAGS) \
  19. al_draw_scaled_bitmap(BMP, SX, SY, SW, SH, DX, DY, DW, DH, FLAGS)
  20. #define image_drawpart(BMP, SX, SY, SW, SH, DX, DY, FLAGS) \
  21. al_draw_bitmap_region(BMP, SX, SY, SW, SH, DX, DY, FLAGS)
  22. #define image_free(BMP) al_destroy_bitmap(BMP)
  23. #define font_free(FONT) al_destroy_font(FONT)
  24. #define font_lineheight(FONT) al_get_font_line_height(FONT)
  25. #define font_ascent(FONT) al_get_font_ascent(FONT)
  26. #define font_descent(FONT) al_get_font_descent(FONT)
  27. #define font_textwidth(FONT,CSTR) al_get_text_width((FONT), (CSTR))
  28. #define font_strwidth(FONT,STR) al_get_ustr_width((FONT), (CSTR))
  29. #define FONT_LEFT ALLEGRO_ALIGN_LEFT
  30. #define FONT_CENTRE ALLEGRO_ALIGN_CENTRE
  31. #define FONT_RIGHT ALLEGRO_ALIGN_RIGHT
  32. #define font_drawtext(FONT, COL, X, Y, FLAGS, CSTR) \
  33. al_draw_text(FONT, COL, X, Y, FLAGS, CSTR)
  34. #define font_drawstr(FONT, COL, X, Y, FLAGS, CSTR) \
  35. al_draw_ustr(FONT, COL, X, Y, FLAGS, CSTR)
  36. #define font_drawjtext(FONT, COL, X1, X2, Y, DIFF, FLAGS, CSTR) \
  37. al_draw_justified_text(FONT, COL, X1, X2, Y, DIFF, FLAGS, CSTR)
  38. #define font_drawjstr(FONT, COL, X1, X2, Y, DIFF, FLAGS, CSTR) \
  39. al_draw_justified_ustr(FONT, COL, X1, X2, Y, DIFF, FLAGS, CSTR)
  40. /** Color shorthands. */
  41. #define color_rgb(R, G, B) al_map_rgb(R, G, B)
  42. #define color_rgba(R, G, B, A) al_map_rgba(R, G, B, A)
  43. #define color_rgbf(R, G, B) al_map_rgb_f(R, G, B)
  44. #define color_rgbaf(R, G, B, A) al_map_rgba_f(R, G, B, A)
  45. #define COLOR_WHITE al_map_rgb(255, 255, 255)
  46. #define COLOR_BLACK al_map_rgb(0 , 0, 0)
  47. #define COLOR_BLUE al_map_rgb(0 , 0, 64)
  48. Image * image_copy_region
  49. (Image * src, int x, int y, int wide, int high, int flags);
  50. #endif