是否可以在 FF 3.6 中使用 Worker 的画布功能?
我目前正在将图像上传器从 Gears 迁移到 Firefox 3.6/HTMLv5。我将 Gears Worker 与 Gears Canvas 结合使用,在上传之前缩小所选照片的比例。通过这样做,我使浏览器窗口保持响应并避免了“您想停止此脚本吗”警告。
然而,这在 HTMLv5 中似乎并不可行:Web Workers 无权访问 DOM,只能接收 JSON 序列化数据。即使我设法序列化所选图像文件的内容,我也不确定是否可以使用工作程序中的 Canvas 对象来执行缩小尺寸。
在没有工作人员的情况下进行缩放可能会导致浏览器在显示数百万像素图像时冻结。有什么想法如何解决这个问题吗?
I'm currently migrating my image uploader from Gears to Firefox 3.6/HTMLv5. I used a Gears Worker in conjunction with Gears Canvas to scale down the selected photos before upload. By doing this, I kept the browser window responsive and avoided the "Do you want to stop this script"-warnings.
However, this doesn't seem to be feasible in HTMLv5: Web Workers don't have access to the DOM and can only receive JSON-serialized data. Even if I managed to serialize the contents of the selected image files, I am not sure if I can use the Canvas object in my worker to perform the downscaling.
Doing the scaling without workers will likely cause browser freezes with multi-megapixel images. Any ideas how to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您自己实现缩放算法,您可以这样做,因为 Workers 中支持 ImageData 对象。如果您需要更多棘手的图像处理技巧,最好的做法是建议对 Web Workers 进行扩展以获得功能。 (例如,通过订阅 WHATWG 列表并在那里描述您的问题。)
If you implement the scaling algorithm yourself you can do it since ImageData objects are supported within Workers. If you need more tricky image manipulation tricks the best course of action would be to propose extensions to Web Workers to gain functionality. (E.g. by subscribing to the WHATWG list and describing your issue there.)