Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lice_stb_gif.cpp 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright 2021 Jean Pierre Cimalando
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. // SPDX-License-Identifier: Apache-2.0
  16. //
  17. #define STBI_ONLY_GIF
  18. #include "lice_stb_generic.hpp"
  19. LICE_IBitmap *LICE_LoadGIF(const char *filename, LICE_IBitmap *bmp, int *nframes)
  20. {
  21. LICE_IBitmap *ret = LICE_LoadSTB(filename, bmp);
  22. if (ret) {
  23. if (nframes) // animation not implemented
  24. *nframes = 1;
  25. }
  26. return ret;
  27. }
  28. class LICE_stb_GIFLoader
  29. {
  30. _LICE_ImageLoader_rec rec;
  31. public:
  32. LICE_stb_GIFLoader()
  33. {
  34. rec.loadfunc = loadfunc;
  35. rec.get_extlist = get_extlist;
  36. rec._next = LICE_ImageLoader_list;
  37. LICE_ImageLoader_list = &rec;
  38. }
  39. static LICE_IBitmap *loadfunc(const char *filename, bool checkFileName, LICE_IBitmap *bmpbase)
  40. {
  41. if (checkFileName) {
  42. const char *p = filename;
  43. while (*p)
  44. p++;
  45. while (p > filename && *p != '\\' && *p != '/' && *p != '.')
  46. p--;
  47. if (stricmp(p, ".gif"))
  48. return nullptr;
  49. }
  50. return LICE_LoadSTB(filename, bmpbase);
  51. }
  52. static const char *get_extlist()
  53. {
  54. return "GIF files (*.GIF)\0*.GIF\0";
  55. }
  56. };
  57. void lice_stb_install_gif_loader()
  58. {
  59. static LICE_stb_GIFLoader loader;
  60. }