No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

70 líneas
1.6 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net>
  5. //
  6. // Lol Engine is free software. It comes without any warranty, to
  7. // the extent permitted by applicable law. You can redistribute it
  8. // and/or modify it under the terms of the Do What the Fuck You Want
  9. // to Public License, Version 2, as published by the WTFPL Task Force.
  10. // See http://www.wtfpl.net/ for more details.
  11. //
  12. #include <lol/engine-internal.h>
  13. #include "../../image/resource-private.h"
  14. namespace lol
  15. {
  16. /*
  17. * Image implementation class
  18. */
  19. class DummyImageCodec : public ResourceCodec
  20. {
  21. public:
  22. virtual char const *GetName() { return "<DummyImageCodec>"; }
  23. virtual ResourceCodecData* Load(char const *path);
  24. virtual bool Save(char const *path, ResourceCodecData* data);
  25. };
  26. //Priority 0 because it's supposed to be the last one
  27. DECLARE_IMAGE_CODEC(DummyImageCodec, 0)
  28. /*
  29. * Public Image class
  30. */
  31. ResourceCodecData* DummyImageCodec::Load(char const *path)
  32. {
  33. if (strcmp("DUMMY", path))
  34. return nullptr;
  35. auto data = new ResourceImageData(new image(ivec2(256)));
  36. auto image = data->m_image;
  37. u8vec4 *pixels = image->lock<PixelFormat::RGBA_8>(), *tmp = pixels;
  38. for (int j = 0; j < 256; j++)
  39. for (int i = 0; i < 256; i++)
  40. {
  41. tmp->r = ((i ^ j) & 1) * 0xff;
  42. tmp->g = (uint8_t)i;
  43. tmp->b = (uint8_t)j;
  44. tmp->a = (((i >> 4) ^ (j >> 4)) & 1) * 0xff;
  45. ++tmp;
  46. }
  47. image->unlock(pixels);
  48. return data;
  49. }
  50. bool DummyImageCodec::Save(char const *path, ResourceCodecData* data)
  51. {
  52. UNUSED(path, data);
  53. return false;
  54. }
  55. } /* namespace lol */