Esempio n. 1
0
"<?php 
        echo $format == $import_format ? ' selected="selected"' : '';
        ?>
><?php 
        echo htmlspecialchars($name . " (" . $import_format . ")");
        ?>
</option><?php 
    }
    ?>
</select>
</form>
<?php 
}
if ($file) {
    $cv = caca_create_canvas(0, 0);
    if (!$cv) {
        die("Can't create canvas\n");
    }
    if (caca_import_file($cv, $file, $format == NULL ? "" : $format) < 0) {
        die("could not import `" . htmlspecialchars($filename) . "'.\n");
    }
    echo caca_export_string($cv, "html3");
} else {
    ?>
See the <a href="export.php">libcaca export test program</a> for an <a
href="export.php?format=caca">example file</a>.<?php 
}
?>
</body>
</html>
Esempio n. 2
0
 *
 *  This program is free software. It comes without any warranty, to
 *  the extent permitted by applicable law. You can redistribute it
 *  and/or modify it under the terms of the Do What the F**k You Want
 *  to Public License, Version 2, as published by Sam Hocevar. See
 *  http://www.wtfpl.net/ for more details.
 */
if (php_sapi_name() != "cli") {
    die("You have to run this program with php-cli!\n");
}
$imports = caca_get_import_list();
if ($argc < 2 || $argc > 3) {
    $msg = $argv[0] . ": wrong argument count\n" . "usage: " . $argv[0] . " file [<format>]\n" . "where <format> is one of:\n";
    foreach ($imports as $format => $name) {
        $msg .= " \"" . $name . "\" (" . $format . ")\n";
    }
    die($msg);
}
$cv = caca_create_canvas(0, 0);
if (!$cv) {
    die("Can't create canvas\n");
}
if (caca_import_file($cv, $argv[1], $argc >= 3 ? $argv[2] : "") < 0) {
    die($argv[0] . ": could not open `" . $argv[1] . "'.\n");
}
$dp = caca_create_display($cv);
if (!$dp) {
    die("Can't create display\n");
}
caca_refresh_display($dp);
caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1);
Esempio n. 3
0
File: caca.php Progetto: dns/libcaca
 function importFile($path, $codec)
 {
     return caca_import_file($this->cv, $path, $codec);
 }
Esempio n. 4
0
    }
    ?>
</select>
</form>
<?php 
    $export_php = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : 'export.php';
    ?>
<iframe frameborder="0" name="preview" id="preview" width="820" height="620" style="margin: 0; padding: 0; border: none; width: 100%"></iframe>
</body>
</html>
<?php 
    exit(0);
}
if ($file) {
    $cv = caca_create_canvas(0, 0);
    if (caca_import_file($cv, $file, "") < 0) {
        die("`" . htmlspecialchars($filename) . "' has unknown format\n");
    }
} else {
    $cv = caca_create_canvas(WIDTH, HEIGHT);
    for ($y = 0; $y < 256; $y++) {
        for ($x = 0; $x < 256; $x++) {
            $r = $x;
            $g = (255 - $y + $x) / 2;
            $b = $y * (255 - $x) / 256;
            imagesetpixel($pixels, $x, $y, imagecolorallocate($pixels, $r, $g, $b));
        }
    }
    $dither = caca_create_dither($pixels);
    if ($format == "ansi" || $format == "utf8") {
        caca_set_dither_charset($dither, "shades");