Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image creation script problem

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
This is part of a image creation script.
All the vars appear to be making the right noises but it does not produce any output.
Is the syntax of the reference to $culler[$i] correct?

Code:
for($i=0;$i<100;$i++){
	$rgb = ImageColorAt($im, 1, $i); 
	$r[$i] = ($rgb >> 16) & 0xFF; 
	$g[$i] = ($rgb >> 8) & 0xFF; 
	$b[$i] = $rgb & 0xFF; 
	$culler[$i] = imagecolorallocate ($newim,$r[$i],$g[$i],$b[$i]);
	imageline($newim,0,$i,$width,$i,[red]\$culler[$i][/red]);
}
header ("Content-type: image/jpeg");
imagejpeg($newim);

Keith
 
I have had to work round it by dropping the culler array altogether. I need the array later in the script but I will have to re-create it.
Code:
$culler = imagecolorallocate ($newim,200,200,200);
for($i=0;$i<100;$i++){
	$rgb = ImageColorAt($im, 1, $i); 
	$r[$i] = ($rgb >> 16) & 0xFF; 
	$g[$i] = ($rgb >> 8) & 0xFF; 
	$b[$i] = $rgb & 0xFF; 
	[red]$culler[/red] = imagecolorallocate ($newim,$r[$i],$g[$i],$b[$i]);
	imageline($newim,0,$i,$width,$i,$culler);
}
header ("Content-type: image/jpeg");
imagejpeg($newim);

Keith
 
Try:
Code:
$culler = imagecolorallocate ($newim,200,200,200);
for($i=0;$i<100;$i++){
    $rgb = ImageColorAt($im, 1, $i); 
    $r[$i] = ($rgb >> 16) & 0xFF; 
    $g[$i] = ($rgb >> 8) & 0xFF; 
    $b[$i] = $rgb & 0xFF; 
    $culler = imagecolorallocate ($newim,$r[$i],$g[$i],$b[$i]);
    imageline($newim,0,$i,$width,$i,$culler);
    $cullerarray[$i] = $culler ; // save the culler here.
}
header ("Content-type: image/jpeg");
imagejpeg($newim);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top