flex bitmapData 绘制 - 如何设置在哪里绘制

发布于 2024-10-07 13:05:59 字数 505 浏览 0 评论 0原文

我有一个类,它创建一个带有合并 2 个 IBitmapDrawable 的 bitmapData 的类。 其中一个是 24*20,另一个是 16*16。 我想在 bitmapData 对象中先绘制较小的,其宽度和高度为 24*20 但我想把它画在大边界的中心。

有谁知道该怎么做? 谢谢...

if (baseIcon) {
    var result:BitmapData = new BitmapData(baseIconWidth,baseIconHeigt,true, 0x00FFFFFF);
    result.draw(baseIcon,new Matrix(1, 0, 0, 1, 0, 0));
    if (indicatorIcon) {
       result.draw(indicatorIcon,new Matrix(1, 0, 0, 1, 0, 0));
    }
    bitmapData = result;
    baseIcon = null;            
}

i have a class thats create a class with bitmapData that merge 2 IBitmapDrawable.
one of them is 24*20 while the other is 16*16.
i want to draw the smaller first in a bitmapData object which its width and height are 24*20
but i want to draw it in the center of the big bounds.

does anyone know's how to do that?
thanks...

if (baseIcon) {
    var result:BitmapData = new BitmapData(baseIconWidth,baseIconHeigt,true, 0x00FFFFFF);
    result.draw(baseIcon,new Matrix(1, 0, 0, 1, 0, 0));
    if (indicatorIcon) {
       result.draw(indicatorIcon,new Matrix(1, 0, 0, 1, 0, 0));
    }
    bitmapData = result;
    baseIcon = null;            
}

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

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

发布评论

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

评论(2

寂寞美少年 2024-10-14 13:05:59

试试这个:

if (baseIcon) {
    var result:BitmapData = new BitmapData(baseIconWidth,baseIconHeigt,true, 0x00FFFFFF);
    var m:Matrix = new Matrix();
    m.translate(baseIconWidth/2 - baseIcon.width/2,baseIconHeight/2 - baseIcon.height/2);
    result.draw(baseIcon,m);
    if (indicatorIcon) {
       result.draw(indicatorIcon,new Matrix(1, 0, 0, 1, 0, 0));
    }
    bitmapData = result;
    baseIcon = null;            
}

Try this:

if (baseIcon) {
    var result:BitmapData = new BitmapData(baseIconWidth,baseIconHeigt,true, 0x00FFFFFF);
    var m:Matrix = new Matrix();
    m.translate(baseIconWidth/2 - baseIcon.width/2,baseIconHeight/2 - baseIcon.height/2);
    result.draw(baseIcon,m);
    if (indicatorIcon) {
       result.draw(indicatorIcon,new Matrix(1, 0, 0, 1, 0, 0));
    }
    bitmapData = result;
    baseIcon = null;            
}
嘦怹 2024-10-14 13:05:59

查看BitmapData.draw中的matrix参数,使用转换后的矩阵。

Look at matrix parameter in BitmapData.draw, use translated matrix.

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