有没有办法对Flash AS3采取帧的快照,然后将其保存为JPEG将其、快照、没有办法、保存为

2023-09-08 12:32:55 作者:地球到星星没有捷径

有没有办法对Flash AS3采取帧的快照,然后使用类将其保存为JPEG格式与出

is there a way for flash AS3 to take a snapshot of the frame and then save it as jpeg with out using classes

推荐答案

当然...尝试谷歌上搜索......有吨的方法。这是假设你确定与标准闪存类。如果从字面上的意思是没有阶级都那么祝你好运。

Sure... try searching on google... there are tons of ways. That is assuming you are ok with the standard flash classes. If you literally mean no classes at all then good luck to you.

下面是这样做的一种方式。 闪光的PHP上传

Here is one way of doing it. flash-php-upload

基本上的关键点是您创建一个JPEG恩codeR即会连接code图像JPEG格式(你可以做一个PNG,如果你想也)是这样的:

Basically the key points are you create a JPEG Encoder that will encode your image a JPEG (you could do a PNG if you want also) like this:

var jpgEncoder:JPGEncoder;
jpgEncoder = new JPGEncoder(90);

接下来,您连接code。通过先绘制其数据为位图,然后ecoding的阶段:

Next you encode the stage by first drawing its data to a bitmap, then ecoding that:

var bitmapData:BitmapData = new BitmapData(stage.width, stage.height);
bitmapData.draw(stage, new Matrix());

img = jpgEncoder.encode(bitmapData);

现在这取决于闪烁您使用的是你可以做如下提示用户保存:

Now depending on what flash you are using you can do the following to prompt the user to save:

var file:FileReference = new FileReference();
file.save(img, "filename.jpg");

或者,如果你想将它保存到你可以做以下服务器:

Or if you want to save it to the server you can do the following:

var sendHeader:URLRequestHeader = new URLRequestHeader("Content-type","application/octet-stream");
var sendReq:URLRequest = new URLRequest("path-to-php.php");

sendReq.requestHeaders.push(sendHeader);
sendReq.method = URLRequestMethod.POST;
sendReq.data = img;

var sendLoader:URLLoader;
sendLoader = new URLLoader();
sendLoader.addEventListener(Event.COMPLETE, imageSentHandler);
sendLoader.load(sendReq);

和那么你就需要用下面的PHP文件:

And then you need a PHP file with the following:

<?php
if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) {
$filename = "filename.jpg";
$fp = fopen( $filename,"wb");
fwrite( $fp, $GLOBALS[ 'HTTP_RAW_POST_DATA' ] );
fclose( $fp );
echo "filename=".$filename."&base=".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"]);
}

请注意,我没有测试此code错误,但总的想法是正确的,你应该能够使用它,让你需要为你的程序的更改。     ?>

Please be aware that I have not tested this code for errors but the general idea is correct and you should be able to use it and make the changes you need for your program. ?>