从另一个域加载外部图像 [英] Loading external images from another domain

查看:146
本文介绍了从另一个域加载外部图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能从另一个域加载图像(JPG,PNG,GIF),并操纵像素? 我的猜测是,下载图像时/复制它在我的域名。

Is it possible to load an image(jpg, png, gif) from another domain and manipulate the pixels? I guess when the image is downloaded/copied it is in my domain.

使用装载机,并添加内容,我在调试器中得到一个错误的图像组件。 我想有一些跨域政策在这里工作。

Using the Loader and add the content to an Image component I get an error in my debugger. I guess there are some cross domain polices at work here.

不过,我需要更多的肯定,这在移动之前是如何工作的。 我猜想,如果不能加载图像直接我可以创建一个本地代理。

But I need to be more sure how this works before moving on. I guess, if it is not possible to load the image directly I could create a local proxy.

可能有人请赐教?

在此先感谢。

推荐答案

如果你是从加载图像其他域,您可以(与您的域上市有crossdomain.xml的),那么所有你需要做的是设置你的加载器上下文,因此默认加载检查策略文件。

If the other domain that you're loading the images from allows you to ( has a crossdomain.xml with your domain listed there ) then all you need to do is setup your loader context so it loads checks for policy files by default.

下面是一个片断:

var loaderContext:LoaderContext = new LoaderContext(true);
var loader:Loader = new Loader();
loader.load(new URLRequest('http://someserver.com/yourImage.jpg'),loaderContext);

否则,您可能需要使用一些服务器端语言来加载图像和你域写。之后做到这一点,你应该能够做到你需要的所有操作。

Otherwise, you might need to use some server side language to load the image and write it on you domain. After that is done, you should be able to do all the manipulation you need.

古德勒克, 乔治

这篇关于从另一个域加载外部图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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