image.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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
  31. {
  32. /* image metrics */
  33. rt_uint16_t w, h;
  34. /* image engine */
  35. struct rtgui_image_engine* engine;
  36. /* image private data */
  37. void* data;
  38. };
  39. typedef struct rtgui_image rtgui_image_t;
  40. /* init rtgui image system */
  41. void rtgui_system_image_init(void);
  42. struct rtgui_image* rtgui_image_create_from_file(const char* type, const char* filename, rt_bool_t load);
  43. struct rtgui_image* rtgui_image_create_from_mem(const char* type, const rt_uint8_t* data, rt_size_t length, rt_bool_t load);
  44. void rtgui_image_destroy(struct rtgui_image* image);
  45. /* register an image engine */
  46. void rtgui_image_register_engine(struct rtgui_image_engine* engine);
  47. /* blit an image on DC */
  48. void rtgui_image_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect);
  49. #endif