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