source: libcaca/trunk/caca-php/examples/www/dithering.php @ 3215

Last change on this file since 3215 was 3215, checked in by bsittler, 11 years ago

add missing whitespace before /> so that the XHTML works in more plain-HTML parsers; quote attributes in double quotes rather than single quotes for the same reason

File size: 1.3 KB
Line 
1<?php
2header('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</head>
12<body>
13<?php
14/*
15 *  dithering.php      sample program for libcaca php binding
16 *  Copyright (c) 2008 Nicolas Vion <nico@yojik.eu>
17 *
18 *  This program is free software. It comes without any warranty, to
19 *  the extent permitted by applicable law. You can redistribute it
20 *  and/or modify it under the terms of the Do What The Fuck You Want
21 *  To Public License, Version 2, as published by Sam Hocevar. See
22 *  http://sam.zoy.org/wtfpl/COPYING for more details.
23 */
24
25$src = "logo-caca.png";
26$img = imagecreatefrompng(dirname(__FILE__)."/".$src);
27if (!$img)  {
28        die("Can not open image.\n");
29}
30
31$dither = caca_create_dither($img);
32if (!$dither)  {
33        die("Can not create dither. Maybe you compiled caca-php without gd support.\n");
34}
35
36$canvas = caca_create_canvas(100, 40);
37
38caca_dither_bitmap($canvas, 0, 0, caca_get_canvas_width($canvas), caca_get_canvas_height($canvas), $dither, $img);
39
40echo caca_export_string($canvas, "html3");
41echo "<img src=\"./$src\" alt="" />";
42
43?>
44</body>
45</html>
46
Note: See TracBrowser for help on using the repository browser.