位图数据的尺寸(宽度和高度)
我是 Flex 新手,我有一个关于 bitmapData 及其宽度和高度的问题。
通常,您在 AS3 中像这样设置位图数据:
var bd:BitmapData = new BitmapData(100, 100, true, 0x00000000);
var bm:Bitmap = new Bitmap(bd);
但在 Flex 中嵌入图像的工作方式如下:
[Embed(source="../../../../../assets/sprites/asteroids/asteroid_32_full.gif")]
public static const Asteroid1:Class;
var imageBM:Bitmap = new Library.Asteroid1();
当使用位图数据(例如 imageBM.bitmapData)时,我不必再设置宽度和高度。即使没有设置位图数据的宽度和高度,Flash 播放器是否会自动知道位图数据的宽度和高度?我完全不知道这个话题,因为我不知道Flash播放器是否总是知道bitmapData的尺寸。如果不设置位图数据的尺寸,这会导致问题吗?
I'm new to flex and I have a question concerning bitmapData and its width and height.
Normally you set up bitmapData like this in AS3:
var bd:BitmapData = new BitmapData(100, 100, true, 0x00000000);
var bm:Bitmap = new Bitmap(bd);
But in Flex embedding an an image works like this:
[Embed(source="../../../../../assets/sprites/asteroids/asteroid_32_full.gif")]
public static const Asteroid1:Class;
var imageBM:Bitmap = new Library.Asteroid1();
When using the bitmapData (e.g. imageBM.bitmapData) I don't have to set up width and height any more. Does the Flash player know the width and height of a bitmapData automatically even when NOT setting up the bitmapData's width and height? I'm totally unaware about this topic because I don't know whether the Flash player always knows the dimensions of a bitmapData. Could this cause problems when not setting up the dimensions of a bitmapData?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您从头开始生成 BitmapData 对象,则必须设置宽度和高度。
如果它是通过图像导入自动生成的,则不需要。它是通过图像导入过程在幕后设置的。
If you're generating a BitmapData object from scratch, you have to set the width and height.
If it's being generated automatically via image import, you don't. It's set under the covers by the image import process.