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.
 
 
 

50 lines
1.1 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 <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. u8vec4 *data = image.Lock<PixelFormat::RGBA_8>();
  27. LOLUNIT_ASSERT(data);
  28. LOLUNIT_ASSERT_EQUAL((int)data[0].r, 0x00);
  29. LOLUNIT_ASSERT_EQUAL((int)data[0].g, 0x00);
  30. LOLUNIT_ASSERT_EQUAL((int)data[0].b, 0x00);
  31. LOLUNIT_ASSERT_EQUAL((int)data[255].r, 0xff);
  32. LOLUNIT_ASSERT_EQUAL((int)data[255].g, 0xff);
  33. LOLUNIT_ASSERT_EQUAL((int)data[255].b, 0xff);
  34. image.Unlock(data);
  35. }
  36. };
  37. } /* namespace lol */