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