Código:
y este codigo es el de la pagina php que se llama webcam4.phptheCam = Camera.get();
if(theCam == null) {
System.showSettings(3);
return;
} else {
theCam.setQuality(8192,90);
theCam.setMode(320,240,5);
theCam.smoothing = 1;
webcam.attachVideo(theCam);
}
import flash.display.BitmapData;
import flash.geom.Matrix;
import PrintScreen;
/* creamos nueva película, donde se copiará la instantánea de la cámara. */
bitmapData = new BitmapData(320, 240, false, 0xFFFFFF);
/*this.createEmptyMovieClip("bmp1", this.getNextHighestDepth());*/
this.createEmptyMovieClip("bmp1", 0);
bmp1.attachBitmap(bitmapData, 2, "auto", true);
var myMatrix:Matrix = new Matrix();
myMatrix.scale(2,2);
bmp1._x = 330;snap._y = 0;
enviar._visible = false;
preloader._visible = false
captura.onPress = function () {
bitmapData.draw(webcam,myMatrix);
enviar._visible = true;
enviar.enabled = true;
}
enviar.onPress = function () {
enviar.enabled = false;
captura._visible = false;
preloader._visible = true;
output();
}
var listener:Object = new Object();
// copy in progress...
listener.onProgress = function(target:MovieClip, loaded:Number, total:Number){
var perc = Math.round((loaded/total)*100)
preloader.perc.text = "procesando... " + perc + "%"
preloader.barra._xscale = perc;
}
// copy is complete, send the result LoadVars to PHP
listener.onComplete = function(target:MovieClip, load_var:LoadVars){
bitmapData.dispose();
preloader._visible = false;
enviar._visible = false;
var label:TextField = bmp1.createTextField("label", 1, 0, 0, 320, 240);
label.multiline = true;
label.wordWrap = true;
label.text = "Por favor espere, los datos están siendo enviados al servidor y este proceso puede tardar algunos minutos, dependiendo de su velocidad hacia internet...\n\nSea paciente y espere sin hacer muecas ;-)";
var my_fmt:TextFormat = new TextFormat();
my_fmt.font = 'Trebuchet Ms';
my_fmt.size = 15;
my_fmt.color = 0xFF0000;
label.setTextFormat(my_fmt);
load_var.send("webcam4.php", "", "POST")
}
function output() {
pn = new PrintScreen(); // initialize the PrintScreen class
pn.addListener( listener ); // assign a listener
pn.print(this,330,0,320,240) // copy the _root
preloader.perc.text = "computing... 0%"
}
Código:
Me imagino que en este codigo hay q capturar la imagen o algo, espero me ayuden gracias... <?php
error_reporting(0);
/**
* Get the width and height of the destination image
* from the POST variables and convert them into
* integer values
*/
$w = (int)$_POST['width'];
$h = (int)$_POST['height'];
// create the image with desired width and height
$img = imagecreatetruecolor($w, $h);
// now fill the image with blank color
// do you remember i wont pass the 0xFFFFFF pixels
// from flash?
imagefill($img, 0, 0, 0xFFFFFF);
$rows = 0;
$cols = 0;
// now process every POST variable which
// contains a pixel color
for($rows = 0; $rows < $h; $rows++){
// convert the string into an array of n elements
$c_row = explode(",", $_POST['px' . $rows]);
for($cols = 0; $cols < $w; $cols++){
// get the single pixel color value
$value = $c_row[$cols];
// if value is not empty (empty values are the blank pixels)
if($value != ""){
// get the hexadecimal string (must be 6 chars length)
// so add the missing chars if needed
$hex = $value;
while(strlen($hex) < 6){
$hex = "0" . $hex;
}
// convert value from HEX to RGB
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
// allocate the new color
// N.B. teorically if a color was already allocated
// we dont need to allocate another time
// but this is only an example
$test = imagecolorallocate($img, $r, $g, $b);
// and paste that color into the image
// at the correct position
imagesetpixel($img, $cols, $rows, $test);
}
}
}
/*
//añade marca de agua, cambiar la ruta a la fuente TTF
$string="ymipollo.com";
$font = "/home/toro/mdn/test/thin.ttf";
$size=6;
$fsize = @ImagettFbbox($size,45,$font,$string);
$black = imagecolorallocate($img, 0, 0, 0);
$white = imagecolorallocate($img, 255, 255, 255);
$dx = abs($fsize[2]-$fsize[0]); $dy = abs($fsize[5]-$fsize[3]);
$x = (imagesx($img)/2) - ($dx/2); $y = (imagesy($img)-$dy)-10;
imagettftext($img,$size,45,300,$y,$black,$font,$string);
imagettftext($img,$size,45,301+1,$y+1,$white,$font,$string); */
// print out the correct header to the browser
header("Content-type:image/jpeg");
//display the image
imagejpeg($img, "", 90);
imagedestroy($img);
?>


