您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

dithering.php 1.3 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. header('Content-Type: text/html; charset=UTF-8');
  3. ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  5. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  7. <head>
  8. <title>Caca power!</title>
  9. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  10. </head>
  11. <body>
  12. <?php
  13. /*
  14. * dithering.php sample program for libcaca php binding
  15. * Copyright (c) 2008 Nicolas Vion <nico@yojik.eu>
  16. *
  17. * This program is free software. It comes without any warranty, to
  18. * the extent permitted by applicable law. You can redistribute it
  19. * and/or modify it under the terms of the Do What The Fuck You Want
  20. * To Public License, Version 2, as published by Sam Hocevar. See
  21. * http://sam.zoy.org/wtfpl/COPYING for more details.
  22. */
  23. $src = "logo-caca.png";
  24. $img = imagecreatefrompng(dirname(__FILE__)."/".$src);
  25. if (!$img) {
  26. die("Can not open image.\n");
  27. }
  28. $dither = caca_create_dither($img);
  29. if (!$dither) {
  30. die("Can not create dither. Maybe you compiled caca-php without gd support.\n");
  31. }
  32. $canvas = caca_create_canvas(100, 40);
  33. caca_dither_bitmap($canvas, 0, 0, caca_get_canvas_width($canvas), caca_get_canvas_height($canvas), $dither, $img);
  34. echo caca_export_string($canvas, "html3");
  35. echo "<img src=\"./$src\" alt=\"\" />";
  36. ?>
  37. </body>
  38. </html>