MAX_SCENE_HEIGHT) ? MAX_SCENE_HEIGHT : $height; $height = ($height < MIN_SCENE_HEIGHT) ? MIN_SCENE_HEIGHT : $height; $feature_z = MAX_DEPTH-$height*(MAX_DEPTH-MIN_DEPTH)/256; $sep = (int)((float)(EYE_SEP*$feature_z)/($feature_z+OBS_DIST)); $left_px = (int)$x-($sep/2); $right_px = (int)$x+($sep/2); if(($left_px >= 0) && ($right_px < $img_width)) { if(!isset($buffer[$left_px][$y])) $buffer[$left_px][$y] = $colors[rand(1,255)]; $buffer[$right_px][$y] = $buffer[$left_px][$y]; } } for($x = 0; $x < $img_width;$x++) if(!isset($buffer[$x][$y])) $buffer[$x][$y] = $colors[rand(1,255)]; } /* Output PNG File */ for($y = 0; $y < $img_height; $y++) { for($x = 0; $x < $img_width; $x++) { imagesetpixel($stereo_img,$x, $y, $buffer[$x][$y]); } } header("Content-type: image/png"); $black = imagecolorclosest($stereo_img, 0,0,0); $white = imagecolorclosest($stereo_img, 0xff, 0xff, 0xff); imagefilledrectangle($stereo_img, 0, $img_height-20, $img_width, $img_height, $black); imagestring($stereo_img, 1, 5, $img_height-10, "Made at http://www.coggeshall.org/stereogram.php", $white); imagepng($stereo_img); ?>