240*240 px lik bi mc nin printini pixel pixel php ye gönderip jpg olarak alabiliyorum kodlar aşağıdadır, fakat flash dan yollanan post değerinin boyutu büyük oluyor haliyle upload çok zaman alıyor.
POST değerini sıkıştırıp yollayabilirmiyiz ? php, gelen veriyi açıp sonra işlese ?
veya farklı bi küçültme yöntemi varmı ?
import flash.display.BitmapData;
shaF.onPress = function() {
output();
};
function output() {
snap = new BitmapData(mc._width, mc._height);
snap.draw(mc);
var pixels:Array = new Array();
var w:Number = 240//snap.width;
var h:Number = 240//snap.height;
for (var a = 0; a<=w; a++) {
for (var b = 0; b<=h; b++) {
var tmp = snap.getPixel(a, b).toString(16);
pixels.push(tmp);
}
}
var output:LoadVars = new LoadVars();
output.img = pixels.toString();
output.height = h;
output.width = w;
output.send("show.php", "_blank", "POST"); //output
}
stop(); <?php
$data = explode(",", $_POST['img']);
$width = $_POST['width'];
$height = $_POST['height'];
$image=imagecreatetruecolor( $width ,$height );
$background = imagecolorallocate( $image ,0 , 0 , 0 );
//Copy pixels
$i = 0;
for($x=0; $x<=$width; $x++){
for($y=0; $y<=$height; $y++){
$int = hexdec($data[$i++]);
$color = ImageColorAllocate ($image, 0xFF & ($int >> 0x10), 0xFF & ($int >> 0x8), 0xFF & $int);
imagesetpixel ( $image , $x , $y , $color );
}
}
//Output image and clean
header( "Content-type: image/jpeg" );
ImageJPEG( $image );
imagedestroy( $image );
?>