image.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. struct rtgui_image;
  20. struct rtgui_image_engine
  21. {
  22. const char* name;
  23. struct rtgui_list_node list;
  24. /* image engine function */
  25. rt_bool_t (*image_check)(struct rtgui_filerw* file);
  26. rt_bool_t (*image_load)(struct rtgui_image* image, struct rtgui_filerw* file, rt_bool_t load);
  27. void (*image_unload)(struct rtgui_image* image);
  28. void (*image_blit)(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect);
  29. };
  30. struct rtgui_image_palette
  31. {
  32. rtgui_color_t* colors;
  33. rt_uint32_t ncolors;
  34. };
  35. typedef struct rtgui_image_palette rtgui_image_palette_t;
  36. struct rtgui_image
  37. {
  38. /* image metrics */
  39. rt_uint16_t w, h;
  40. /* image engine */
  41. const struct rtgui_image_engine* engine;
  42. /* image palette */
  43. rtgui_image_palette_t* palette;
  44. /* image private data */
  45. void* data;
  46. };
  47. typedef struct rtgui_image rtgui_image_t;
  48. /* init rtgui image system */
  49. void rtgui_system_image_init(void);
  50. #if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
  51. struct rtgui_image* rtgui_image_create_from_file(const char* type, const char* filename, rt_bool_t load);
  52. struct rtgui_image* rtgui_image_create(const char* filename, rt_bool_t load);
  53. #endif
  54. struct rtgui_image* rtgui_image_create_from_mem(const char* type, const rt_uint8_t* data, rt_size_t length, rt_bool_t load);
  55. void rtgui_image_destroy(struct rtgui_image* image);
  56. /* register an image engine */
  57. void rtgui_image_register_engine(struct rtgui_image_engine* engine);
  58. /* blit an image on DC */
  59. void rtgui_image_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect);
  60. struct rtgui_image_palette* rtgui_image_palette_create(rt_uint32_t ncolors);
  61. #endif