Pukey
Threadersteller
Dabei seit: 07.09.2006
Ort: Mannheim/Heidelberg
Alter: 37
Geschlecht:
|
Verfasst Fr 01.10.2010 15:01
Titel [AS2] MovieClip to Jpg |
|
|
Hallo Freunde,
ich habe mir in Action Script 2 einen kleinen Painter geschrieben. Also quasi eine Leinwand auf der ich á la Paint mit verschiedenen Brush-größen und Farben malen kann.
Dort gibt es dann einen Print Button der mir diese Leinwand als JPG speichern soll.
Das er mir den movie Clip in der Flash Datei aufzeichnet habe ich geschaft. Nur die kommunikation zu der PHP Datei stimmt noch nicht richtig. Er spuckt mir nur ein schwarzes Bild aus... Warum?
Code: |
import flash.display.BitmapData;
import flash.geom.Matrix;
import flash.filters.ColorMatrixFilter;
canvasAbove._width = 500;
canvasAbove._height = 350;
print_btn_mc.onRelease = function() {
var pixels:Array = new Array()
//Create a new BitmapData
var snap = new BitmapData(canvasAbove._width, canvasAbove._height, true, 0xffffff);
//Copy video image
snap.draw(painting);
//Ausgabe der Aufzeichnung in der Flash Datei
drawclip.attachBitmap(snap,this.getNextHighestDepth());
drawclip._width = 250;
drawclip._height = 250;
var w:Number = snap.width, tmp
var h:Number = snap.height
var a:Number = 0
for (i= 0; i<250; i++)
{
for (j= 0; j< 250; j++)
{
var pixelValue = bd.getPixel32(i, j);
var alphaValue = pixelValue >> 24 & 0xFF;
var rgbValue = pixelValue & 0xffffff;
var resultAlpha = alphaValue * (factor );
bd.setPixel32(j, i, resultAlpha << 24 | rgbValue);
}
}
//Create the LoadVars object and pass data to PHP script
var output:LoadVars = new LoadVars();
output.img = pixels.toString();
output.height = drawclip._width;
output.width = drawclip._height;
//The page (and this movie itself) should be in a server to work
output.send("show.php","output","POST");
};
|
Dateien liegen auf einem lokalen Xampp. GD Library is auch drauf.
show.php
Code: |
<?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=(function_exists("imagecreatetruecolor"))?imagecreatetruecolor( $width ,$height ):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);
}
}
//Output image and clean
header( "Content-type: image/png" );
ImageJPEG( $image );
imagedestroy( $image );
?>
|
Gegooglet habe ich auch schon. Hier einige meiner gefundenen Tutorials.
http://www.quasimondo.com/archives/000572.php
http://www.flash-db.com/Tutorials/snapshot/snapshot.php?page=3
http://www.sephiroth.it/tutorials/flashPHP/print_screen/
danke schon mal für eure Hilfe.
|
|