|
בעיה בקבלת נתונים מ FLASH.נשלחים נתנוים ב POST אבל מגיע מידע לא נכון
הי.
אני מנסה לבנות מערכת שמציגה מצלמת אינטרנט שיושבת על שרת כלשהו ובלחיצת כפתור, "תופסת" תמונה ושולחת לקובץ PHP ע"מ לשמור או להציג על המסך.
הבעיה היא, שהמידע שנשלח לא מגיע כמו שהו לקובץ ה-PHP.
אני שולח STRING שמכיל את ערכי הפיקסלים של התמונה, כל ערך מופרד ב-",".
כשאני מדפיס את התוצאה (trace) דרך הפלאש, זה נראה בסדר.
אבל כשאני מדפיס את מה שמתקבל בקובץ PHP, כל הערכים מקבלים "0"!
אין לי מושג איפה זה נופל.
אני מצרף קוד:
אם למישהו יש רעיון מה יכולה להיות הסיבה ואיך פותרים אותה, אני אשמח לדעת.
תודה רבה מראש.
flash:
import flash.display.BitmapData;
import flash.geom.*
capture_mc.onPress = function()
{
snap();
output();
}
var now=new BitmapData(myVideo.width,myVideo.height);
var out=new BitmapData(myVideo.width,myVideo.height);
var m=new Matrix();
var output_mc = null;
m.scale((myVideo._xscale/100),(myVideo._yscale/100))
this.createEmptyMovieClip("output_mc",this.getNextHighestDepth())
output_mc.attachBitmap(out,1)
output_mc._alpha = 0;
output_mc._x= 0
output_mc._y= 0
function snap()
{
output_mc._alpha = 0;
now.draw(myVideo,m)
done=now.clone()
out.fillRect(out.rectangle,0xFFFFFF)
out.threshold(done,new Rectangle(0, 0, myVideo.height, myVideo.height),new Point(0, 0),">=", (100/100)*0xFFFFFF, 0xFFFFFF, 0xFFFFFF, true)
}
function output()
{
var pixels:Array = new Array();
var w:Number = out.width;
var h:Number = out.height;
for (var a = 0; a<=w; a++)
{
for (var b = 0; b<=h; b++)
{
var tmp = out.getPixel(a, b).toString(16);
pixels.push(tmp);
}
}
var output:LoadVars = new LoadVars();
output.img = pixels.toString();
trace(output.img);
output.h = h;
output.w = w;
output.send("show.php", "output", "POST");
}
php:
<?php
$data = explode(",", $_POST['img']);
$width = $_POST['w'];
$height = $_POST['h'];
$matrix = $_POST['img'];
print_r($matrix);
$image=imagecreatetruecolor( $width ,$height );
$background = imagecolorallocate( $image ,0 , 0 , 0 );
$rows = 0;
$cols = 0;
for($rows = 0; $rows < $height; $rows++)
{
$c_row = $data;
for($cols = 0; $cols < $width; $cols++)
{
$value = $c_row[$cols];
if($value != "")
{
$hex = $value;
while(strlen($hex) < 6)
{
$hex = "0" . $hex;
}
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
$test = imagecolorallocate($image, $r, $g, $b);
imagesetpixel($image, $cols, $rows, $test);
}
}
}
//ImageJPEG( $image,"images/image.jpeg", 90);
//header("Content-disposition: attachment; filename=image.jpeg");
//header( "Content-type: image/jpeg" );
//ImageJPEG( $image);
//imagedestroy( $image );
?>
|