在 Image 中显示巨大的、可滚动的图像? [英] Displaying huge, scrollable images in Image?

查看:18
本文介绍了在 Image 中显示巨大的、可滚动的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试显示可能大于可用显示区域的图像文件(jpg、png、gif).我在 cCanvas 中嵌入了一个图像(用于滚动),但是大图像没有完全显示.

I'm trying to show image files (jpg, png, gif) that can be larger than the available display area. I've embedded an Image inside a cCanvas (to get scrolling), but the large images are not completely displayed.

非常大的图像(例如 2480 x 3507)的顶部或顶部和底部被滚动图像剪裁.

Very large images (e.g. 2480 x 3507) have the top or the top and bottom of the image clipped withing the scrolling Image.

使用 mx.controls.Image 可以显示的最大图形是多少?

What is the largest graphic one can display using the mx.controls.Image ?

谢谢

推荐答案

2880 像素的限制是针对 BitmapDatas,对于 DisplayObjects 有 8191 像素的限制.您可以使用此处提供的 BitmapDataUnlimited 类绕过这些限制:http://code.google.com/p/bitmapdataunlimited/

The 2880 pixels limit is for BitmapDatas, for DisplayObjects there's a limit of 8191 pixels. You can bypass these limits by using the BitmapDataUnlimited-class available here: http://code.google.com/p/bitmapdataunlimited/

但是,如果性能很重要,我建议让如此大的图像由多个较小的图像组成.即使您不重用这些较小的,也不注意将它们从 displayList 中删除或将它们的可见属性设置为 false,仍然会提高性能,因为 Flash 会自动检测到它们在舞台之外,而不必被渲染.

However, if performance is important I'd recommend letting such large images consist of multiple smaller ones instead. Even if you don't reuse these smaller ones or take care of removing them from the displayList or setting their visible-property to false there will still be a performance gain as flash automatically detects that they're outside of the stage and wont have to be rendered.

我忘了说 2880px 的限制只适用于手动创建 BitmapData 时,大于它的图像仍然可以加载,并且可以访问和操作它们的 BitmapDatas(大于 2880px).您可以轻松拥有一个位图数据与视口一样大的位图,然后您可以通过执行以下操作来设置其位图数据:

I forgot saying that the 2880px-limit only applies when manually creating BitmapDatas, images bigger than that can still be loaded in, and their BitmapDatas (which are bigger than 2880px) can be accessed and manipulated. You could easily have a Bitmap with a bitmapData as large as the viewport, then you can set its bitmapData by doing something like:

viewportBitmapData.copyPixels(sourceBitmapData, new Rectangle(x,y,viewportWidth, viewPortHeight), new Point(0,0))

滚动时,您可以简单地在每一帧上执行上述操作或者如果性能很重要,你可以在滚动时(如果 scrollingDistance 小于 viewportSize)使用 viewportBitmapData.scroll(x,y) 来移动整个 bitmapData,然后只复制新的像素.

When scrolling, you could simply do the above on each frame Or if performance is important, you can when scrolling (if scrollingDistance is less than viewportSize) use viewportBitmapData.scroll(x,y) to shift the whole bitmapData, and then copy only the new pixels.

这篇关于在 Image 中显示巨大的、可滚动的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆