Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

40 righe
1.1 KiB

  1. #!/usr/bin/php5
  2. <?php
  3. /*
  4. * dithering.php sample program for libcaca php binding
  5. * Copyright (c) 2008 Nicolas Vion <nico@yojik.eu>
  6. *
  7. * This program is free software. It comes without any warranty, to
  8. * the extent permitted by applicable law. You can redistribute it
  9. * and/or modify it under the terms of the Do What the Fuck You Want
  10. * to Public License, Version 2, as published by Sam Hocevar. See
  11. * http://www.wtfpl.net/ for more details.
  12. */
  13. if (php_sapi_name() != "cli") {
  14. die("You have to run this program with php-cli!\n");
  15. }
  16. $img = imagecreatefrompng(dirname(__FILE__)."/logo-caca.png");
  17. if (!$img) {
  18. die("Can not open image.\n");
  19. }
  20. $dither = caca_create_dither($img);
  21. if (!$dither) {
  22. die("Can not create dither. Maybe you compiled caca-php without gd support.\n");
  23. }
  24. $canvas = caca_create_canvas(0, 0);
  25. $display = caca_create_display($canvas);
  26. if (!$display) {
  27. die("Can not create display.\n");
  28. }
  29. caca_dither_bitmap($canvas, 0, 0, caca_get_canvas_width($canvas), caca_get_canvas_height($canvas), $dither, $img);
  30. caca_refresh_display($display);
  31. caca_get_event($display, CACA_EVENT_KEY_PRESS, -1);
  32. ?>