从另一个域加载外部图像图像、加载

2023-09-08 14:13:55 作者:七月殇

是否有可能从另一个域加载图像(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('https://m.xsw88.com/allimgs/daicuo/20230908/956.png.com'),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.

古德勒克, 乔治