<?
// Convert SWF Drawing API data to JPEG
// Example by Jerry Jasuta
// grab the drawing data
$data=$HTTP_POST_VARS["data"];

// create truecolor image for jpeg output
// and pallette image for drawing creation
$image=imagecreatetruecolor(300,200);
$imagelines=imagecreate(300,200);

// set background and line colors
$background=imagecolorallocate($imagelines,255,255,255);
$linecolor=imagecolorallocate($imagelines,0,0,0);

// split up the drawing data into lines
$lines=explode("-",$data);

// loop through the lines
for($l=0;$l<count($lines)-1;$l++){

  
// split up the line data
  
$lineData=explode("_",$lines[$l]);

  
// draw the line image
  
imageline($imagelines,$lineData[0],$lineData[1],$lineData[2],$lineData[3],$linecolor);

}  
// end drawing data loop

// copy the pallette drawing image to the truecolor jpeg image
imagecopyresampled($image,$imagelines,0,0,0,0,300,200,300,200);

// save the jpeg to file
imagejpeg($image,"created.jpg");

// free up the image allocations
imagedestroy($image);
imagedestroy($imagelines);

// print out the hmtl page
print "<html>
<head>
<title>SWF Drawing Converted To JPEG Using PHP and GD</title>
</head>
<body bgColor='cccccc'>
<center>
SWF Drawing Converted To JPEG Using PHP and GD<p>
<img src='created.jpg'>
</center>
</body>
</html>
"
;
?>


Free Hosting Provide By: Web Hosting Service http://www.hostrocket.com
Make $50 Per Sale: VoIP Affiliate Program http://affiliates.viatalk.com
ViaTalk: Internet Phone Service http://www.viatalk.com