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

Last change on this file since 4333 was 4333, checked in by Sam Hocevar, 10 years ago

Large source code cleanup, getting rid of spaces, tabs, and svn keywords.

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.