25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

16_movie.cpp 1.2 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // Lol Engine — GIF encoding sample
  3. //
  4. // Copyright © 2016 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. #if HAVE_CONFIG_H
  13. # include "config.h"
  14. #endif
  15. #include <lol/engine.h>
  16. #include "loldebug.h"
  17. int main(int argc, char **argv)
  18. {
  19. UNUSED(argc, argv);
  20. lol::ivec2 size(256, 256);
  21. lol::movie movie(size);
  22. if (!movie.open_file("16_movie.gif"))
  23. return EXIT_FAILURE;
  24. for (int i = 0; i < 256; ++i)
  25. {
  26. lol::image im(size);
  27. lol::array2d<lol::u8vec3> &data = im.lock2d<lol::PixelFormat::RGB_8>();
  28. for (int y = 0; y < size.y; ++y)
  29. for (int x = 0; x < size.x; ++x)
  30. {
  31. data[x][y].r = x * i / 2;
  32. data[x][y].g = x / 4 * 4 * y / 16 + i;
  33. data[x][y].b = y + i;
  34. }
  35. im.unlock2d(data);
  36. if (!movie.push_image(im))
  37. break;
  38. }
  39. movie.close();
  40. return 0;
  41. }