Código 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=(imagecreate( $width ,$height ));
imagefill($image, 0, 0, 0xFFFFFF);
//Copy pixels
$i = 0;
for($x=0; $x<=$width; $x++){
for($y=0; $y<=$height; $y++){
$r = hexdec("0x".substr( $data[$i] , 2 , 2 ));
$g = hexdec("0x".substr( $data[$i] , 4 , 2 ));
$b = hexdec("0x".substr( $data[$i++] , 6 , 2 ));
$color = imagecolorallocate($image, $r, $g, $b);
imagesetpixel ($image,$x,$y,$color);
}
}
por si os puede ayudar aqui os dejo la parte flash AS 2
Código PHP:
function capture(nr)
{
snapshot = new BitmapData(950, 520);
//draw the current state of the Video object into
//the bitmap object with no transformations applied
snapshot.draw(_root ,new Matrix());
var t:MovieClip = createEmptyMovieClip("bitmap_mc", 0);
t._x = 0;
t._y = 0;
t._xscale = t._yscale = 100;
//display the specified bitmap object inside the movie clip
t.attachBitmap(snapshot,1);
var filterArray = new Array(myFilters[nr]);
t.filters = filterArray;
attachMovie("print_but","bot",100,{_x:t._x + t._width -450, _y:t._y + t._height / 2});
}
//Create a new bitmapdata, resize it 50 %, pass image data to a server script
// using a LoadVars object (large packet)
function output(who)
{
//preloader visible
preloader._visible = true;
//Here we will copy pixels data
var pixels:Array = new Array();
//Create a new BitmapData
var snap = new BitmapData(who.width, who.height);
//Matrix to scale the new image
myMatrix = new Matrix();
myMatrix.scale(0.5,0.5);
//Copy video image
snap.draw(who,myMatrix);
//Uncoment this line if you want to apply filters instead of just capturing source
// results should be adjusted based on your library version, not recomended
//snap.applyFilter(snap, snap.rectangle, snap.rectangle.topLeft, myFilters[nr])
var w:Number = snap.width, tmp;
var h:Number = snap.height;
//Build pixels array using an onEnterframe to avoid timeouts, capture a row per iteration, show a progressbar
var a:Number = 0;
this.onEnterFrame = function()
{
for (var b = 0; b <= h; b++)
{
var alpha:String = (snap.getPixel32(a, b) >> 24 & 0xFF).toString(16);
var red:String = (snap.getPixel32(a, b) >> 16 & 0xFF).toString(16);
var green:String = (snap.getPixel32(a, b) >> 8 & 0xFF).toString(16);
var blue:String = (snap.getPixel32(a, b) & 0xFF).toString(16);
tmp = "0x" + red + green + blue;
pixels.push(tmp);
}
perc = int((a * 100) / w);
preloader.perc.text = perc + " %";
preloader.barra._xscale = perc;
a++;
if (a > w)
{//Finish capturing
preloader._visible = false;
sendData(pixels,h,w,nombre);
//free memory
snap.dispose();
delete this.onEnterFrame;
}
};
}
//Capture a clip into a BitmapData object and pass whitout resizing
function outputClip(who)
{
//preloader visible
preloader._visible = true;
//Here we will copy pixels data
var pixels:Array = new Array();
//Create a new BitmapData
var snap = new BitmapData(who._width, who._height);
snap.draw(who);
var w:Number = snap.width, tmp;
var h:Number = snap.height;
//Build pixels array using an onEnterframe to avoid timeouts, capture a row per iteration, show a progressbar
var a:Number = 0;
this.onEnterFrame = function()
{
for (var b = 0; b <= h; b++)
{
tmp = snap.getPixel32(a, b).toString(16);
pixels.push(tmp.substr(1));
}
perc = int((a * 100) / w);
preloader.perc.text = perc + " %";
preloader.barra._xscale = perc;
a++;
if (a > w)
{//Finish capturing
preloader._visible = false;
sendData(pixels,h,w,nombre);
//free memory
snap.dispose();
delete this.onEnterFrame;
}
};
}
function sendData(pixels:Array, h:Number, w:Number)
{
//Create the LoadVars object and pass data to PHP script
var output:LoadVars = new LoadVars();
output.img = pixels.toString();
output.height = h;
output.width = w;
output.nombre = nombre;
output.archivo=archivo;
output.precio = teeTotals.myTotal;
output.imgdelantera=imgdelantera;
output.imgtrasera=imgtrasera;
output.menS=menS;
output.menM=menM;
output.menL=menL;
output.menXL=menXL;
output.menXXL=menXXL;
output.menXXXL=menXXXL;
output.womenXS=womenXS;
output.womenS=womenS;
output.womenM=womenM;
output.womenL=womenL;
output.womenXL=womenXL;
output.womenXXL=womenXXL;
//The page (and this movie itself) should be in a server to work
output.send("show.php","output","POST");