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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 <cmath>
  14. #include "core.h"
  15. #include "lol/unit.h"
  16. namespace lol
  17. {
  18. LOLUNIT_FIXTURE(ImageTest)
  19. {
  20. LOLUNIT_TEST(OpenImage)
  21. {
  22. Image *image = Image::Create("data/gradient.png");
  23. ivec2 size = image->GetSize();
  24. LOLUNIT_ASSERT_EQUAL(size.x, 256);
  25. LOLUNIT_ASSERT_EQUAL(size.y, 16);
  26. uint8_t *data = image->GetData();
  27. LOLUNIT_ASSERT(data);
  28. LOLUNIT_ASSERT_EQUAL((int)data[0], 0x00);
  29. LOLUNIT_ASSERT_EQUAL((int)data[1], 0x00);
  30. LOLUNIT_ASSERT_EQUAL((int)data[2], 0x00);
  31. LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 0], 0xff);
  32. LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 1], 0xff);
  33. LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 2], 0xff);
  34. Image::Destroy(image);
  35. }
  36. };
  37. } /* namespace lol */