Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/11/2006, 16:43
Avatar de WinGFX
WinGFX
 
Fecha de Ingreso: mayo-2006
Ubicación: Bogotá
Mensajes: 86
Antigüedad: 20 años, 5 meses
Puntos: 3
Exclamación Capturar movie con elementos y enviarlos como JPG

Hola a todos!!!


He estado programando Flash en estos días pero me he encontrado con algo que no se si se pueda hacer.

Estoy intentando hacer una captura de un MovieClip (teniendo en cuenta que tenemos otros simbolos, líneas y formas que lo conforman) para guardarlo a una imagen JPEG.

Ya tengo el script PHP que me permite crear y guardar la imagen.

El problema lo tengo es cuando Flash crea los píxeles que son enviados pero solo veo que me guarda un mapa de bit, no los objetos que mencioné....


Alguno sabe como resolverlo??

Por poco................ como tengo el AS que lo procesa? Aqui está:


Código PHP:
// Carga de el objeto a instanciar para la captura
import flash.display.BitmapData;
import flash.filters.DropShadowFilter
import flash
.filters.BlurFilter;
import flash.geom.Matrix;
import flash.filters.ColorMatrixFilter;
//Build color Matrix Filter
var matrix:Array = new Array();
matrix = matrix.concat([1, 0, 0, 1, 0]); // red
matrix = matrix.concat([0, 1, 0, 0, 0]); // green
matrix = matrix.concat([0, 0, 1, 1, 0]); // blue
matrix = matrix.concat([0, 0, 0, 1, 0]); // alpha
var filterCol:ColorMatrixFilter = new ColorMatrixFilter(matrix);
//
preloader._visible = 0;
//
function outputClip(who){
 
//preloader visible 
 
_root.toda.p.gotoAndStop("guardar");
 
resultsImg.play();
 
resultsImg.preloader._visible = 1;
 
//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)
  
resultsImg.preloader.perc.text = perc+" %"
  
resultsImg.preloader.barra._xscale = perc     
  a
++
  if(
a>w){ //Finish capturing
   
resultsImg.preloader._visible = false
   sendData
(pixels, h, w)
   
//free memory
   
snap.dispose()
   
delete this.onEnterFrame
  
}
 }
}
sendData = function(pixels:Array, h:Number, w:Number) {
 
//Create the LoadVars object and pass data to PHP script 
 
output = new LoadVars()
 
output.img = pixels.toString() 
 
output.height = h 
 output
.width = w 
 
//The page (and this movie itself) should be in a server to work 
 
output.sendAndLoad("chargeImage.php", output, "POST");
 
output.onLoad = function(ok) {
  if(
ok) {
   
hMsg = this.msg;
   if(
hMsg == 'NoGD') {
    
getURL("javascript:alert('No se puede realizar la imagen, no se dispone de GD')");
   } else if(
hMsg == 'not_created') {
    
getURL("javascript:alert('No se pudo guardar la imagen')");
   } else if(
hMsg == 'created_saved') {
    
resultsImg.gotoAndPlay(31);
   }
  } else {
   
getURL("javascript:alert('No se puede establecer conexion')");
  }
 }
};

_root.toda.p.bguardar.onPress = function() { outputClip(_root.toda.p); };
stop(); 
__________________
"Si piensas en que harás mañana, mejor hazlo hoy!"

Consejos para las buenas preguntas