image-file.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. struct gs_image_file {
  18. gs_texture_t *texture;
  19. enum gs_color_format format;
  20. uint32_t cx;
  21. uint32_t cy;
  22. bool is_animated_gif;
  23. bool frame_updated;
  24. bool loaded;
  25. gif_animation gif;
  26. uint8_t *gif_data;
  27. uint8_t **animation_frame_cache;
  28. uint8_t *animation_frame_data;
  29. uint64_t cur_time;
  30. int cur_frame;
  31. int cur_loop;
  32. int last_decoded_frame;
  33. uint8_t *texture_data;
  34. gif_bitmap_callback_vt bitmap_callbacks;
  35. };
  36. typedef struct gs_image_file gs_image_file_t;
  37. EXPORT void gs_image_file_init(gs_image_file_t *image, const char *file);
  38. EXPORT void gs_image_file_free(gs_image_file_t *image);
  39. EXPORT void gs_image_file_init_texture(gs_image_file_t *image);
  40. EXPORT bool gs_image_file_tick(gs_image_file_t *image,
  41. uint64_t elapsed_time_ns);
  42. EXPORT void gs_image_file_update_texture(gs_image_file_t *image);