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.
 
 
 

75 lines
1.3 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/image-private.h"
  15. using namespace std;
  16. namespace lol
  17. {
  18. /*
  19. * Image implementation class
  20. */
  21. DECLARE_IMAGE_LOADER(DummyImageData, 0)
  22. {
  23. public:
  24. virtual bool Open(char const *);
  25. virtual bool Close();
  26. virtual void *GetData() const;
  27. private:
  28. uint8_t *pixels;
  29. };
  30. /*
  31. * Public Image class
  32. */
  33. bool DummyImageData::Open(char const *path)
  34. {
  35. size = ivec2(256);
  36. format = Image::FORMAT_RGBA;
  37. pixels = (uint8_t *)malloc(256 * 256 * 4 * sizeof(*pixels));
  38. uint8_t *parser = pixels;
  39. for (int j = 0; j < 256; j++)
  40. for (int i = 0; i < 256; i++)
  41. {
  42. *parser++ = ((i ^ j) & 1) * 0xff;
  43. *parser++ = (uint8_t)i;
  44. *parser++ = (uint8_t)j;
  45. *parser++ = (((i >> 4) ^ (j >> 4)) & 1) * 0xff;
  46. }
  47. return true;
  48. }
  49. bool DummyImageData::Close()
  50. {
  51. free(pixels);
  52. return true;
  53. }
  54. void * DummyImageData::GetData() const
  55. {
  56. return pixels;
  57. }
  58. } /* namespace lol */