Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/11/2008, 22:27
Avatar de K-Yezaad
K-Yezaad
 
Fecha de Ingreso: octubre-2005
Mensajes: 140
Antigüedad: 18 años, 6 meses
Puntos: 3
AS3: Problema con JPGEncode (regresa valor nulo)

Estoy trabajando con una aplicacion que crea "snapshots" de una webcam, hasta ahora todo bien, logro hacer la captura con el metodo draw() con éxito. Cuando trato de codificar con JPGEncode, y lo paso a un php el resultado es una imagen vacia de 4bytes.

Este es mi codigo:

Código:
public function takeSnapshot():void{
		var snapshotHolder:UIComponent = new UIComponent();
		var snapshot:BitmapData = new BitmapData(320, 240, true, 0x00000000);
		var snapshotbitmap:Bitmap = new Bitmap(snapshot);
		snapshotHolder.y = 0;
		snapshotHolder.addChild(snapshotbitmap);
		if(videoCapture.numChildren > 0){
		videoCapture.removeChildAt(0);
		}
		videoCapture.addChildAt(snapshotHolder, 0);
		snapshot.draw(webcam);
		
		//hasta este punto todo funciona perfecto
		var jpgEncoder:JPGEncoder = new JPGEncoder(85);
		var jpgStream:ByteArray = jpgEncoder.encode(snapshot);
		
		var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
		var jpgURLRequest:URLRequest = new URLRequest("data_process.php?name=sketch.jpg");
		jpgURLRequest.requestHeaders.push(header);
		jpgURLRequest.method = URLRequestMethod.POST;
		jpgURLRequest.data = jpgStream;
		navigateToURL(jpgURLRequest, "_blank");*/
	    }
El codigo del php es:
Código:
if (isset($HTTP_RAW_POST_DATA))
{
	// get bytearray
	$jpg = $HTTP_RAW_POST_DATA;

	//add headers for download dialog-box
	header('Content-Type: image/jpeg');
	echo strlen($jpg);
}
Cualquier ayuda sera de agradecerse, google no me ha dado mucha info.. si encuentro alguna vuelta o alguna solucion la pondre por aqui