image.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * File : image.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-10-16 Bernard first version
  13. */
  14. #ifndef __RTGUI_IMAGE_H__
  15. #define __RTGUI_IMAGE_H__
  16. #include <rtgui/dc.h>
  17. #include <rtgui/filerw.h>
  18. #include <rtgui/region.h>
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. struct rtgui_image;
  23. struct rtgui_image_engine
  24. {
  25. const char *name;
  26. struct rtgui_list_node list;
  27. /* image engine function */
  28. rt_bool_t (*image_check)(struct rtgui_filerw *file);
  29. rt_bool_t (*image_load)(struct rtgui_image *image, struct rtgui_filerw *file, rt_bool_t load);
  30. void (*image_unload)(struct rtgui_image *image);
  31. void (*image_blit)(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *rect);
  32. };
  33. struct rtgui_image_palette
  34. {
  35. rtgui_color_t *colors;
  36. rt_uint32_t ncolors;
  37. };
  38. typedef struct rtgui_image_palette rtgui_image_palette_t;
  39. struct rtgui_image
  40. {
  41. /* image metrics */
  42. rt_uint16_t w, h;
  43. /* image engine */
  44. const struct rtgui_image_engine *engine;
  45. /* image palette */
  46. rtgui_image_palette_t *palette;
  47. /* image private data */
  48. void *data;
  49. };
  50. typedef struct rtgui_image rtgui_image_t;
  51. /* init rtgui image system */
  52. void rtgui_system_image_init(void);
  53. #if defined(RTGUI_USING_DFS_FILERW)
  54. struct rtgui_image_engine *rtgui_image_get_engine_by_filename(const char *fn);
  55. struct rtgui_image *rtgui_image_create_from_file(const char *type, const char *filename, rt_bool_t load);
  56. struct rtgui_image *rtgui_image_create(const char *filename, rt_bool_t load);
  57. #endif
  58. struct rtgui_image *rtgui_image_create_from_mem(const char *type, const rt_uint8_t *data, rt_size_t length, rt_bool_t load);
  59. void rtgui_image_destroy(struct rtgui_image *image);
  60. /* get image's rect */
  61. void rtgui_image_get_rect(struct rtgui_image *image, struct rtgui_rect *rect);
  62. /* register an image engine */
  63. void rtgui_image_register_engine(struct rtgui_image_engine *engine);
  64. /* blit an image on DC */
  65. void rtgui_image_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *rect);
  66. struct rtgui_image_palette *rtgui_image_palette_create(rt_uint32_t ncolors);
  67. #ifdef __cplusplus
  68. }
  69. #endif
  70. #endif