English 中文(简体)
AS3:复制PNG图像造成透明度损失
原标题:AS3: Duplicating a PNG image causes loss of transparency

我正在使用洛纳德·马克斯装上外部的巴布亚新几内亚,并在许多地方展示,因此我使用以下代码复制图像:

var cd:ContentDisplay = ContentDisplay(loader.getContent("name"));
var b1 = Bitmap(cd.rawContent);
var old = b1.bitmapData;
var bmp = new Bitmap(b1);

container.addChild(bmp);

The original image has a 50% on the alpha channel, but when I create the new bitmap from from the same bitmapData object, it does not preserve the alpha channel.

如果我试图复制甲型频道(见下文的代码;如果我理解正确的话,甲型频道就会从自己复制到本身),那么新形象的透明度就存在,但该法典却留下了一个错误。

bmp.copyChannel(old, new Rectangle(0, 0, old.width, old.height), new Point(), BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA);

错误:

Reference错误: Error #1069: Property copyChannel not found on flash.display.Bitmap and there is no default value.
    at barmask/frame1()

我怎么能够重复一个PNG,并保持甲型的透明度......最好不出现错误?

P.s. 请原谅任何明显错误,我是《新行动》b。

最佳回答

create your BitmapData instance, passing 3 parameters to the constructor: new BitmapData(w, h, true), Boolean value is transparency
also check the transparent property of the source BitmapData

问题回答

他的答复非常接近完成:

new BitmapData(w, h, true, 0); 

最后一个确保闪电的房地产包括新形象的背景。 这应当解决你的问题。 这要么是“0”,要么是0x000。

2. 比图 t有一种影印法,因为错误说:

不这样做:

bmp.copyChannel(...

你们需要这样做:

bmp.bitmapData.copyChannel(...




相关问题
Non transparent image in transparent block

logo_area { background-color: #d9e670; filter:alpha(opacity=25); opacity:0.25; } and another div: #logo_image { background: url(../images/logo.png) no-repeat center 50%; } <div id="...

How to represent binary transparency?

Lately I ve been interested in representing uncompressed bitmaps in memory. However, one thing I m not sure how to implement properly is binary transparency. E.g., I start out with something like this:...

Transparent PNG in PictureBox

I am trying to make simple app that allows one to compare image to transparent PNG templates, by dragging the template over picture. For this I need a way to create a PictureBox that will contain the ...

Neither IE7 nor IE8 render PNG transparency

I ve got an element, an image, defined as instrument in css and for the life of me I cannot get it to properly display a png with transparency in IE7 or IE8 -- works fine in Safari and FF. I really ...

Hex colors: Numeric representation for "transparent"?

I am building a web CMS in which the user can choose colours for certain site elements. I would like to convert all colour values to hex to avoid any further formatting hassle ("rgb(x,y,z)" or named ...

PNG transparency in Interface Builder

I m adding an Image View in Interface Builder with a transparent PNG (A logo in the Navigation Bar) but the transparent pixels seems to render as white.. I searched for PNG in Interface Builder but ...

热门标签