- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我有一个运行在 pixie.strd6.com 的站点,图像通过 Amazon S3 托管,并带有 images.pixie.strd6.com 的 CNAME。
我希望能够将这些图像绘制到 HTML5 Canvas 上并调用 getImageData 方法,但它抛出 Error: SECURITY_ERR: DOM Exception 18
我试过设置 window.domain = "pixie.strd6.com"
,但这没有任何效果。
此外,$.get("http://dev.pixie.strd6.com/sprites/8516/thumb.png?1293830982", function(data) {console.log(data)})
还会引发错误:XMLHttpRequest cannot load <a href="http://dev.pixie.strd6.com/sprites/8516/thumb.png?1293830982" rel="noreferrer noopener nofollow">http://dev.pixie.strd6.com/sprites/8516/thumb.png?1293830982</a>. Origin <a href="http://pixie.strd6.com" rel="noreferrer noopener nofollow">http://pixie.strd6.com</a> is not allowed by Access-Control-Allow-Origin.
理想情况下,HTML5 Canvas 不会阻止调用 getImageData
来自子域。我研究过在 S3 中设置 Access-Control-Allow-Origin header ,但没有成功。
非常感谢任何帮助或解决方法。
最佳答案
Amazon recently announced CORS support
We're delighted to announce support for Cross-Origin Resource Sharing (CORS) in Amazon S3. You can now easily build web applications that use JavaScript and HTML5 to interact with resources in Amazon S3, enabling you to implement HTML5 drag and drop uploads to Amazon S3, show upload progress, or update content. Until now, you needed to run a custom proxy server between your web application and Amazon S3 to support these capabilities.
To configure your bucket to allow cross-origin requests, you create a CORS configuration, an XML document with rules that identify the origins that you will allow to access your bucket, the operations (HTTP methods) will support for each origin, and other operation-specific information. You can add up to 100 rules to the configuration. You add the XML document as the cors subresource to the bucket.
关于HTML5 Canvas getImageData 和同源策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4672643/
我所需要的只是获取 Canvas 上单个像素的状态,但我注意到它非常慢。 这是我的 JS var state = ctx.getImageData(x,y,1,1).data; state = 'rg
如何使用 .getImageData() 从给定元素的背景图像中获取数据?项目已经在使用 jQuery,因此欢迎使用 jQuery 解决方案。 最佳答案 getImageData方法只会为您提供来自c
当图像被绘制到 Canvas 中时,如何在js中使用getImageData()? (我分别需要每个图像的数据。) 最佳答案 这是一种方法: // get the imageData for the
这个问题在这里已经有了答案: Why does changing an Array in JavaScript affect copies of the array? (12 个答案) Pass-b
因此,我在 中创建的“上下文”变量上使用函数 getImageData。部分,当我做一些事情,比如画一个矩形然后做 ctx.getImageData.data[0] 它会显示我在 Canvas 上画
您好,我有这个脚本可以检查透明像素和非透明像素。现在我做到了,所以结果来自鼠标悬停在 100px x 100px 的矩形: var data = ctx.getImageData(100,100, c
我正在尝试从图像中输出像素值。图片加载正确;此处的另一个答案表明浏览器正在尝试在图像加载完成之前读取像素,但我可以看到它在 alert() 触发时已加载。 function initContext(c
先行者:我知道已经有人问过关于这个主题的几个问题,但似乎没有一个提供直接的纯 JavaScript 解决方案。 所以我在尝试使用context.getImageData()之类的东西从 Canvas
当下面的代码返回上一张上传的图片而不是当前图片的值时,有人可以告诉我哪里出了问题吗? var imageLoader = document.getElementById('imageLoade
我正在创建一个移动网络应用程序游戏,让用户可以在屏幕上滑动来清除它。我正在尝试编写一个智能函数来检测几乎整个 Canvas 何时是透明的。 我有一个间隔,每秒调用下面的函数来进行检查。它应该工作的方式
我正在尝试获取源 Canvas 的内容,对其进行剪辑,然后将其绘制到另一个 Canvas 上。即使我的代码在使用 src PNG/new Image() 组合时工作得很好,但当源内容来自另一个 Can
为了从特定坐标的图像中获取颜色,我使用了这个答案 get-pixel-color-from-canvas-on-mouseover .然而在Powerpoint在 Microsoft 的第 56 页上
我正在尝试覆盖内置方法 CanvasRenderingContext2D.getImageData()。我想重写实现,以便修改后的函数使用 Canvas 上下文修改 Canvas ,然后调用原始函数,
分析 HTML5 Canvas 中的像素数据: var width = 960; var height = 500; var canvas = document.getEle
缩小 Canvas 后,我遇到了 context.getImageData() 问题。我已将 Canvas 添加到 HTML 页面: 我在 Canvas 上绘制了图像,就像按钮一样。我正在测试 Alp
这个问题已经有答案了: Create Canvas element with image and append to parent (2 个回答) 已关闭 8 年前。 所以,我有一个这样的函数: va
我试图通过canvas标签读取图像数据,每次我尝试检索和显示该数据时,它都出现0。即使我将数据抓取限制为 1 个像素,它也会出现“0,0,0,0”。奇怪的是,我可以使用 fillRect 并检索该数据
由于上一篇文章太困惑,我在这里开了一个新线程。 我正在尝试使用 JavaScript 从我的服务器检索 .png 文件中的确切 RGBA 值。 代码如下: img = new Image(); img
我正在加载一个 PNG 并尝试检查它是否完全不透明,这意味着 alpha channel 在整个图像上接近 100%。因此,我使用 Canvas 和 2D-Context 来获取像素数据并循环检查
我正在尝试制作一个颜色选择器。我的代码在 getImageData 之后以某种方式停止。我找不到解决方案... 还有其他方法获取像素值吗?或者问题是我正在尝试使用图片的链接? > function d
我是一名优秀的程序员,十分优秀!