简体   繁体   English

如何在带有透明后组的flex中显示png

[英]How to show png in flex with transparent backgroup

with the following code,it shows write backgroup now 用下面的代码,它显示现在写backgroup

<s:BorderContainer width="100%" height="80%" backgroundAlpha="0">
    <s:Image id="bg"  width="100%" height="100%"/>
    <s:Image id="img" width="100%" height="100%"  />
</s:BorderContainer>
var black:BitmapData  = new BitmapData(bg.width,bg.height,false,0X656565);
bg.source = new Bitmap(black);
var bitmap:Bitmap = new Bitmap(data.bytes); //a png BitmapData
img.source = bitmap;

In the statement 在声明中

var black:BitmapData = new BitmapData(bg.width,bg.height,false,0X656565); you have already set the transparency to false. 您已经将透明度设置为false。 Instead try: 而是尝试:

var black:BitmapData  = new BitmapData(bg.width,bg.height,true,0X00000000);

The third parameter sets the transparency to true and allows the bitmapData to take 32 bit colors which includes the alpha values also. 第三个参数将透明度设置为true,并允许bitmapData采用32位颜色,其中还包括alpha值。 The 32 bit color for the transparency part is passed in the 4th parameter, with the first two digits after the 0x standing for alpha=0. 透明度部分的32位颜色在第4个参数中传递,0x之后的前两位代表alpha = 0。

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM