Moze troche OT bedzie (IMG:
http://forum.php.pl/style_emoticons/default/winksmiley.jpg) :
Napisalem kiedys troche inny skrypt, robiacy z obrazka htmlowa tabelke (IMG:
http://forum.php.pl/style_emoticons/default/smile.gif)
Cytat(spenalzo @ 2004-11-03 02:01:20)
mozilla przy 512 Ram ledwo chodzi...
Hehe... Mozilla wysiada (zaczyna żreć 150MB ramu i zwisa) na moim skrypcie przy obazkach 400x400 (IMG:
http://forum.php.pl/style_emoticons/default/smile.gif) Nie mowiac juz o IE ktory powyzej 300x300 zaczyna gubic kolory w polowie komorek (IMG:
http://forum.php.pl/style_emoticons/default/smile.gif)
<?php
function tohex($color){
$color = '0' . $color;
}
return $color;
}
$error = '';
if( !empty($_GET['path']) ) { list($szer, $wys) = $imgsize;
switch($imgsize[ 'mime' ]) {
case 'image/jpeg':
$img = imagecreatefromjpeg($_GET['path']);
break;
case 'image/png':
$img = imagecreatefrompng($_GET['path']);
break;
case 'image/gif':
$img = imagecreatefromgif($_GET['path']);
break;
default:
$error = '<b>Zły format pliku lub plik nie istnieje</b><br><br>';
}
$pixels = $szer * $wys;
$wiersz = 0;
$kolumna = 0;
$px_szer = intval($_GET['px_szer']); $px_wys = intval($_GET['px_wys']); $cellspacing = intval($_GET['cellspacing']); if($px_szer < 1) {
$px_szer = 1;
}
if($px_wys < 1) {
$px_wys = 1;
}
if($cellspacing < 0) {
$cellspacing = 0;
}
}
echo '<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head><title></title><style type=\"text/css\">table, td{border: none;padding: 0px;color:#fff;font-family:verdana;font-size:10pt;}'. (isset($img) ?
'td{width:'. $px_wys .';height: '. $px_szer .';}' : '') .'body{background-color:#000;margin:0;padding:0;}a{color:#fff;}</style><meta http-equiv=\"Content-type\" content=\"text/html; charset=iso-8859-2\"></head><body><table style=\"width:100%;height:100%;\"><tr><td align=\"center\" style=\"width:100%;height:100%;\">';
echo $error . '<form action=\"?\" style=\"margin:0;\"><table width=\"400\"><tr><td>Wpisz ścieżkę pliku (*.jpg, *.png, *.gif):</td><td><input type=\"text\" name=\"path\" value=\"'. (isset($_GET['path']) ?
$_GET['path'] : '') .'\"></td></tr><tr><td>Szerokość piksela:</td><td><input type=\"text\" name=\"px_szer\" value=\"'. (isset($_GET['px_szer']) ?
$_GET['px_szer'] : '') .'\"></td></tr><tr><td>Wysokość piksela:</td><td><input type=\"text\" name=\"px_wys\" value=\"'. (isset($_GET['px_wys']) ?
$_GET['px_wys'] : '') .'\"></td></tr><tr><td>Odstęp między pikselami:</td><td><input type=\"text\" name=\"cellspacing\" value=\"'. (isset($_GET['cellspacing']) ?
$_GET['cellspacing'] : '') .'\"></td></tr></table> <input type=\"submit\" value=\"OK\"></form>'; } else {
echo '<table cellspacing=\"'. $cellspacing .'\"><tr>'; for($i=0; $i < $pixels; $i++) {
$rgb = imagecolorsforindex($img, imagecolorat($img, $kolumna, $wiersz));
echo '<td bgcolor=\"#'. tohex
($rgb['red']) . tohex
($rgb['green']) . tohex
($rgb['blue']).'\"></td>'; if($kolumna == $szer - 1) {
$wiersz++;
$kolumna = 0;
if($i + 1 < $pixels) {
}
} else {
$kolumna++;
}
}
echo '</table><br><br><a href=\"javascript:history.back();\">Wróć</a>'; }
echo '</td></tr></table></body></html>'; ?>