flash AS3 有没有办法拍摄帧快照然后将其保存为 jpeg

发布于 2025-01-08 21:38:56 字数 48 浏览 0 评论 0原文

有没有办法让 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山色无中 2025-01-15 21:38:56

当然...尝试在谷歌上搜索...有很多方法。这是假设您对标准 Flash 课程没问题。如果您的意思是完全不上课,那么祝您好运。

这是一种方法。 flash-php-upload

基本上关键点是你创建的一个 JPEG 编码器,它将您的图像编码为 JPEG(如果您愿意,也可以编码为 PNG),如下所示:

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

接下来,您可以通过首先将其数据绘制到位图来对舞台进行编码,然后对其进行编码:

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

img = jpgEncoder.encode(bitmapData);

现在取决于您使用的闪光灯你可以执行以下操作以提示用户保存:

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

或者,如果您想将其保存到服务器,您可以执行以下操作:

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 文件:

<?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"]);
}
?>

请注意,我尚未测试此代码的错误,但总体思路是正确的,您应该能够使用它并对程序进行所需的更改。

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.

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

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);

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);

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"]);
}
?>

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文