Added image support
This commit is contained in:
parent
75b48badc2
commit
b2a6f0c7af
2 changed files with 34 additions and 8 deletions
19
dBug.php
19
dBug.php
|
@ -406,7 +406,7 @@ class dBug {
|
|||
}
|
||||
|
||||
//!if variable is an image/gd resource type
|
||||
function varIsGDResource($var) {
|
||||
function varIsGDResource(&$var) {
|
||||
$this->makeTableHeader('resource','gd',2);
|
||||
$this->makeTDHeader('resource','Width');
|
||||
$this->checkType(imagesx($var));
|
||||
|
@ -415,15 +415,18 @@ class dBug {
|
|||
$this->checkType(imagesy($var));
|
||||
echo $this->closeTDRow();
|
||||
$this->makeTDHeader('resource','Colors');
|
||||
$this->checkType(imagecolorstotal($var));
|
||||
$this->checkType(imageistruecolor($var)?'TrueColor (16 777 216)':imagecolorstotal($var));
|
||||
echo $this->closeTDRow();
|
||||
/*$this->makeTDHeader('resource','Image');
|
||||
touch('php://temp');
|
||||
imagepng($var,'php://temp');
|
||||
$img=file_get_contents('php://temp');
|
||||
echo $img;
|
||||
|
||||
echo '<img src="data:image/png;base64,'.base64_encode($img).'"/>'.$this->closeTDRow();*/
|
||||
$this->makeTDHeader('resource','Image');
|
||||
|
||||
|
||||
|
||||
ob_start();
|
||||
imagepng($var);
|
||||
$img = ob_get_clean();
|
||||
|
||||
echo '<img src="data:image/png;base64,'.base64_encode($img).'"/>'.$this->closeTDRow();
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
|
|
23
tests.php
23
tests.php
|
@ -67,4 +67,27 @@
|
|||
new dBug($e);
|
||||
}
|
||||
|
||||
|
||||
//drawing Sierpinsky triangle
|
||||
//http://php.net/manual/en/function.imagesetpixel.php
|
||||
$x = 200;
|
||||
$y = 200;
|
||||
$img = imagecreatetruecolor($x, $y);
|
||||
|
||||
$corners[0] = array('x' => 100, 'y' => 10);
|
||||
$corners[1] = array('x' => 0, 'y' => 190);
|
||||
$corners[2] = array('x' => 200, 'y' => 190);
|
||||
|
||||
$red = imagecolorallocate($img, 255, 0, 0);
|
||||
|
||||
for ($i = 0; $i < 10000; $i++) {
|
||||
imagesetpixel($img, round($x),round($y), $red);
|
||||
$a = rand(0, 2);
|
||||
$x = ($x + $corners[$a]['x']) / 2;
|
||||
$y = ($y + $corners[$a]['y']) / 2;
|
||||
}
|
||||
new dBug($img);
|
||||
|
||||
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue