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.

image.cpp 1.1 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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("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 = (uint8_t *)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. }
  35. };
  36. } /* namespace lol */