Complex code can't figure out
Posted: Tue Oct 06, 2009 4:06 am
I am having great difficulty with this code which involves taking in a string of any length and creating an image with a certain width and height and printing the text onto the image having the text wrap through the lines until it reaches the final end of the image at the very bottom right corner, The final result is the text overlaying the image completely fitting in the image top - bottom, left - right with no added spaces etc...)
this may sound odd but has an extremely useful purpose, I have completed the idea with the problem that it mis calculates the width and height, the idea is to have a perfect box but after hundreds of tries it's either too large or too small
I need fast help
this may sound odd but has an extremely useful purpose, I have completed the idea with the problem that it mis calculates the width and height, the idea is to have a perfect box but after hundreds of tries it's either too large or too small
I need fast help
Code: Select all
$data = $_REQUEST['plaindata']; // Get Text
$dataLen = strlen($data); // Get the length of the data
$ii = 1; // Start the incrementer at 1
$dtSt = 0; // Start the string at character 0
$dataLen = sprintf("%u.0",$dataLen); // Take out all decimal points
$dataLen = $dataLen + 1;// padd an extra row and column
$image = imagecreatetruecolor($dataLen * 0.1256,$dataLen * 0.1256); // Create the image based on the column and row sizes at a percentage of 12.56
$BGC = imagecolorallocate($image,"0","0","0"); // Prepare Background color black
imagefill($image,"0","0",$BGC); // Fill image black
$stPX = "0"; // Assign the start pixel cursor position
<< do a loop writing each one and then output image to browser >>