将 ByteArray 发送到 JavaScript [英] Send ByteArray to JavaScript

查看:42
本文介绍了将 ByteArray 发送到 JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 jpg 图像作为 ByteArray 从 as3 发送到 javascript?以及如何在 javascript 中将 ByteArray 转换为图像?

How to send a jpg image as ByteArray from as3 to javascript? And how to convert ByteArray to image in javascript?

推荐答案

当前 Web 浏览器的 JavaScript 和 DOM 实现并没有很好的机制来执行此类操作.

The JavaScript and DOM implementations of current web browsers don't really have good mechanisms for doing this sort of thing.

最好的办法是让 AS3 返回一个带有 base64 编码版本图像的 DATA 协议 URI.现代浏览器(IE8+、FF2+ 等)将接受 DATA URI 作为 IMG 标签的 SRC,并将呈现其中包含的图像.

Your best bet is to have your AS3 return a DATA protocol URI with a base64-encoded version of the image. Modern browsers (IE8+, FF2+, etc) will accept a DATA URI as the SRC of an IMG tag and will render the image contained therein.

http://en.wikipedia.org/wiki/Data_URI_scheme

您必须让 AS3 专家解释如何将字节数组转换为 base64 编码的字符串,但这并不难.

You'll have to have a AS3 expert explain how to turn an byte-array into a base64-encoded string, but it cannot be that hard.

这篇关于将 ByteArray 发送到 JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆