rendered paste body $picture_x = imagesx($image_handler);
$picture_y = imagesy($image_handler);
//$square_pieces = $this->difficulty * 3;
$square_pieces = 200; // 60 x 60 pieces.
$count = 0;
# Time to generate squares.
ob_start(); # lets catch all buffer.
for($i = $square_pieces; $i < $picture_x; $i += $square_pieces) {
$drawing_x = $square_pieces;
for($j = $square_pieces; $j < $picture_y; $j += $square_pieces) {
$drawing_y = $square_pieces;
$temp_pic = imagecreatetruecolor($drawing_x, $drawing_y);
$drawing_x_start = $i > $picture_x ? $i-$picture_x : $i;
$drawing_y_start = $j > $picture_y ? $j-$picture_y : $j;
//echo("Generating ".$drawing_x_start."[startX] and ".$drawing_x."[endX].. => ".$drawing_y_start."[startY] and ".$drawing_y."[stopY]<br>");
imagecopy($temp_pic, $image_handler, 0, 0, $drawing_x_start, $drawing_y_start, $drawing_x, $drawing_y);
imagejpeg($temp_pic,"puz/".$count.".jpg");
imagedestroy($temp_pic);
echo("<img src='puz/".$count.".jpg'>");
$count++;
}
echo("<br />");
}