简体   繁体   中英

How to show png in flex with transparent backgroup

with the following code,it shows write backgroup now

<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. 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. 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.

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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