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.
 
 
 

86 lines
1.8 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include "core.h"
  14. #include "image-private.h"
  15. using namespace std;
  16. namespace lol
  17. {
  18. static bool RegisterAllLoaders()
  19. {
  20. /* We cannot make this an ImageLoader member function, because the
  21. * REGISTER_IMAGE_LOADER macro forward-declares free functions from
  22. * the "lol" namespace. An apparent bug in Visual Studio's compiler
  23. * makes it think these functions are actually in the top-level
  24. * namespace when the forward declaration is in a class member function.
  25. * To avoid the problem, we make the forward declaration in a free
  26. * function. */
  27. #if defined __ANDROID__
  28. REGISTER_IMAGE_LOADER(AndroidImageData)
  29. #endif
  30. REGISTER_IMAGE_LOADER(DummyImageData)
  31. #if defined USE_GDIPLUS
  32. REGISTER_IMAGE_LOADER(GdiPlusImageData)
  33. #endif
  34. #if defined __APPLE__ && defined __MACH__ && defined __arm__
  35. REGISTER_IMAGE_LOADER(IosImageData)
  36. #endif
  37. #if defined __CELLOS_LV2__
  38. REGISTER_IMAGE_LOADER(Ps3ImageData)
  39. #endif
  40. #if defined USE_SDL_IMAGE
  41. REGISTER_IMAGE_LOADER(SdlImageData)
  42. #endif
  43. return true;
  44. }
  45. /*
  46. * Public Image class
  47. */
  48. Image::Image(char const *path)
  49. {
  50. static bool unused = RegisterAllLoaders();
  51. data = ImageLoader::Load(path);
  52. }
  53. ivec2 Image::GetSize() const
  54. {
  55. return data->size;
  56. }
  57. Image::format_t Image::GetFormat() const
  58. {
  59. return data->format;
  60. }
  61. void * Image::GetData() const
  62. {
  63. return data->GetData();
  64. }
  65. Image::~Image()
  66. {
  67. data->Close();
  68. delete data;
  69. }
  70. } /* namespace lol */