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.

63 lines
1.6KB

  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_PNG
  18. #include "lice_stb_generic.hpp"
  19. LICE_IBitmap *LICE_LoadPNG(const char *filename, LICE_IBitmap *bmp)
  20. {
  21. return LICE_LoadSTB(filename, bmp);
  22. }
  23. class LICE_stb_PNGLoader
  24. {
  25. _LICE_ImageLoader_rec rec;
  26. public:
  27. LICE_stb_PNGLoader()
  28. {
  29. rec.loadfunc = loadfunc;
  30. rec.get_extlist = get_extlist;
  31. rec._next = LICE_ImageLoader_list;
  32. LICE_ImageLoader_list = &rec;
  33. }
  34. static LICE_IBitmap *loadfunc(const char *filename, bool checkFileName, LICE_IBitmap *bmpbase)
  35. {
  36. if (checkFileName) {
  37. const char *p = filename;
  38. while (*p)
  39. p++;
  40. while (p > filename && *p != '\\' && *p != '/' && *p != '.')
  41. p--;
  42. if (stricmp(p, ".png"))
  43. return nullptr;
  44. }
  45. return LICE_LoadSTB(filename, bmpbase);
  46. }
  47. static const char *get_extlist()
  48. {
  49. return "PNG files (*.PNG)\0*.PNG\0";
  50. }
  51. };
  52. void lice_stb_install_png_loader()
  53. {
  54. static LICE_stb_PNGLoader loader;
  55. }