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

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

问题描述

是否可以从另一个域加载图像(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天全站免登陆