Всем привет!
У меня есть желание сохранять некоторый мувик как картинку. Нашёл на форуме вполне рабочий код, ну и использовал его. Выглядит он так:
1. Во флеше

Код AS1/AS2:
function sendPicure()
{
var pixels:Array = [];
var bmd:BitmapData = new BitmapData(1000, 369);
var my_matrix:Matrix = new Matrix();
my_matrix.scale(1, 1);
bmd.draw(this.dom, my_matrix);
var w:Number = bmd.width, tmp;
var h:Number = bmd.height;
for(var i=0;i<=w;i++)
{
for(var n=0;n<=h;n++)
{
tmp = bmd.getPixel32(i, n).toString(16);
pixels.push(tmp.substr(1))
}
}
var output:LoadVars = new LoadVars()
output.img = pixels.toString()
output.height = h
output.width = w;
output.send("show.php", "output", "POST");
}
2. PHP скрипт который всё это собирает

PHP код:
//If GD library is not installed, say sorry
if(!function_exists("imagecreate")) die("Sorry, you need GD library to run this example");
//Capture Post data
$data = explode(",", $_POST['img']);
$width = $_POST['width'];
$height = $_POST['height'];
//Allocate image
$image=(function_exists("imagecreatetruecolor"))?imagecreatetruecolor( $width ,$height ):imagecreate( $width ,$height );
$background = imagecolorallocate( $image ,0 , 0 , 0 );
//Copy pixels
$i = 0;
for($x=0; $x<=$width; $x++){
for($y=0; $y<=$height; $y++){
$r = 255-hexdec("0X".substr( $data[$i] , 0 , 2 ));
$g = 255-hexdec("0x".substr( $data[$i] , 2 , 2 ));
$b = 255-hexdec("0x".substr( $data[$i++] , 4 , 2 ));
$color = ($r << 16) | ($g << 8) | $b;
imagesetpixel ( $image , $x , $y , $color );
}
}
//Output image and clean
header( "Content-type: image/jpeg" );
ImageJPEG( $image );
imagedestroy( $image );
Картинка собирается, но неправильно, а вот так:
[IMG]http://img34.**************/img34/3387/tmpc.jpg[/IMG]
Кто нибудь знает в чем может быть причина? Я был бы очень благодарен.