位图数据的尺寸(宽度和高度)

发布于 2024-12-28 03:34:09 字数 580 浏览 3 评论 0原文

我是 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 技术交流群。

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

发布评论

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

评论(1

乱世争霸 2025-01-04 03:34:09

如果您从头开始生成 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.

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