image-file.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /******************************************************************************
  2. Copyright (C) 2016 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include "graphics.h"
  16. #include "libnsgif/libnsgif.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. struct gs_image_file {
  21. gs_texture_t *texture;
  22. enum gs_color_format format;
  23. uint32_t cx;
  24. uint32_t cy;
  25. bool is_animated_gif;
  26. bool frame_updated;
  27. bool loaded;
  28. gif_animation gif;
  29. uint8_t *gif_data;
  30. uint8_t **animation_frame_cache;
  31. uint8_t *animation_frame_data;
  32. uint64_t cur_time;
  33. int cur_frame;
  34. int cur_loop;
  35. int last_decoded_frame;
  36. uint8_t *texture_data;
  37. gif_bitmap_callback_vt bitmap_callbacks;
  38. };
  39. typedef struct gs_image_file gs_image_file_t;
  40. EXPORT void gs_image_file_init(gs_image_file_t *image, const char *file);
  41. EXPORT void gs_image_file_free(gs_image_file_t *image);
  42. EXPORT void gs_image_file_init_texture(gs_image_file_t *image);
  43. EXPORT bool gs_image_file_tick(gs_image_file_t *image,
  44. uint64_t elapsed_time_ns);
  45. EXPORT void gs_image_file_update_texture(gs_image_file_t *image);
  46. #ifdef __cplusplus
  47. }
  48. #endif