25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

67 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 <lol/main.h>
  14. #include "../../image/image-private.h"
  15. namespace lol
  16. {
  17. /*
  18. * Image implementation class
  19. */
  20. class DummyImageCodec : public ImageCodec
  21. {
  22. public:
  23. virtual bool Load(Image *image, char const *path);
  24. virtual bool Save(Image *image, char const *path);
  25. };
  26. DECLARE_IMAGE_CODEC(DummyImageCodec, 0)
  27. /*
  28. * Public Image class
  29. */
  30. bool DummyImageCodec::Load(Image *image, char const *path)
  31. {
  32. UNUSED(path);
  33. image->SetSize(ivec2(256));
  34. u8vec4 *pixels = image->Lock<PixelFormat::RGBA_8>();
  35. for (int j = 0; j < 256; j++)
  36. for (int i = 0; i < 256; i++)
  37. {
  38. pixels->r = ((i ^ j) & 1) * 0xff;
  39. pixels->g = (uint8_t)i;
  40. pixels->b = (uint8_t)j;
  41. pixels->a = (((i >> 4) ^ (j >> 4)) & 1) * 0xff;
  42. ++pixels;
  43. }
  44. image->Unlock(pixels);
  45. return true;
  46. }
  47. bool DummyImageCodec::Save(Image *image, char const *path)
  48. {
  49. UNUSED(path);
  50. return true;
  51. }
  52. } /* namespace lol */