无法创建 Canvas 快照

发布于 2024-08-10 11:09:35 字数 293 浏览 4 评论 0原文

在我的应用程序中,画布对象的高度 = 90 px &宽度 = 86400 px(表示一天的秒数 [60 * 60 * 24] )。画布是可滚动的,用户可以在其中添加或删除组件。

现在,我想要整个画布和画布的快照。将其缩小到 910x30 大小,以便在另一个画布上绘制拍摄的快照。

有人能告诉我如何拍摄这么大的组件的快照吗?

我尝试在 BitmapData 对象中拍摄快照,但由于它的最大宽度为 2880,无法提供整个画布快照。

还有其他可能的想法吗,如果有,请告诉我。

欢迎提出建议。

In my application a canvas object has height = 90 px & width = 86400 px (indicating number of seconds in a day [60 * 60 * 24] ). The canvas is scrollable and the user can add or delete components in that.

Now, I want to have snapshot of the whole canvas & shrink it to size 910x30 to draw taken snapshot in another canvas.

Can anybody tell me how to take snapshot of such large Component?

I have tried to take snapshot in BitmapData object but as it max width is 2880 can not give whole canvas snapshot.

Is there any other Idea possible, if yes please let me know.

Suggestions are welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

灯角 2024-08-17 11:09:35

我还没有对此进行测试,但是如果您完全忽略 BitmapData 并直接从客户端计算机获取结果会怎样?像这样:

var imgSnapshot:ImageSnapshot = ImageSnapshot.captureImage(savableCanvas,72,new PNGEncoder(),false);
            var bArray:ByteArray = imgSnapshot.data;

            var fileRef:FileReference = new FileReference();
            fileRef.save(bArray,"mySavedImage.png");

另外,你的问题是否有拼写错误,86,400像素是要处理的大量数据,你可能应该使用一些服务器端代码和平铺技术来处理这个问题(想想谷歌地图)..这样,如果您使用 php,您可以使用 imagick 并裁剪所需的动态创建的部分。现在,如果它是 8,640px,那么那就是另一个故事了,请查看 Google Code 上的 BitmapDataUnlimited。别担心,它是商业友好的。然而,它确实是有代价的,那么大的画布需要很好地管理,并且在使用后立即丢弃,考虑到 12k x 12k bitmapData 对象据说至少需要 1GB 内存......

I haven't tested this out, but what if you dismissed the BitmapData all together and just took the result straight from the client computer? like this:

var imgSnapshot:ImageSnapshot = ImageSnapshot.captureImage(savableCanvas,72,new PNGEncoder(),false);
            var bArray:ByteArray = imgSnapshot.data;

            var fileRef:FileReference = new FileReference();
            fileRef.save(bArray,"mySavedImage.png");

Also, are there typos on your question, 86,400 pixels is a hell of a lot of data to be dealing with and you should probably be handling this with some server-side code and tiling techniques (think, Google Maps)... this way if you were say using php, you could use imagick and crop the needed dynamically-created-section. Now if it were 8,640px, then that's another story, look into BitmapDataUnlimited on Google Code. And don't worry, it's commercial friendly. However, it does come at a price, that large of a canvas needs to be managed quite well, and discarded immediately after it's use is threw considering that a 12k x 12k bitmapData object is said to be at least 1GB of memory...

断桥再见 2024-08-17 11:09:35

您可以拍摄大画布的多个快照,缩小比例,然后将它们缝合在一起。但是对于如此大的组件,任何类型的位图捕获都将非常密集。

You could take multiple snapshots of your large Canvas, scale down and then stitch them back together. But any kind of bitmap capture for a component that large is going to be very intensive.

梦中的蝴蝶 2024-08-17 11:09:35

您也可以尝试在画布上设置scaleX/scaleY属性,使其适合您的910x30尺寸,然后进行快照。这样 Flash 就会为您扩展。

You may also be able to try to set the scaleX/scaleY property on the canvas so that it fits to your 910x30 size and then doing the snapshot. That way Flash would scale for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文