Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set copyPixels to ignore transparent pixels?
    text
    copied!<p>I have a BitmapData object with transparency (the sourceBitmapData parameter). Every time I use copyPixels() to copy it onto another BitmapData object the transparent pixels replace whatever is beneath them. I would like the copyPixels() function to simply ignore these fully transparent pixels (0x00) and NOT copy them. </p> <p>Any ideas?</p> <p>BTW, I've tried setting the alphaMerge to true but that doesn't solve the issue - the whole source object just goes black and ignores ALL transparency.</p> <p>EDIT:</p> <p>Here are the code snippets;</p> <pre><code>var b:UIComponent = new UIComponent(); b.graphics.beginFill(color, opacity); b.graphics.drawCircle(size * 2, size * 2, size); b.graphics.endFill(); shape = new BitmapData(size * 4, size * 4, true, 0x00FFFFFF); shape.draw(b); rect = new Rectangle(0, 0, size * 4, size * 4); shape.applyFilter(shape, rect, new Point(0, 0), new BlurFilter(20, 20) ); </code></pre> <p>It creates a graphics object (circle in this case) and copies it to the source bitmap and then applies the blur filter.</p> <pre><code>drawBuffer.copyPixels(shape, rect, pnt, null, null, false); </code></pre> <p>After that, it applies the resulting image, several times, over drawBuffer. If alphaMerge is set to true, shape looks like a black blob - it seems that all alpha information is simply ignored and the alpha value is set to 0xFF (note: this is my speculation based on how it looks, I didn't verify it). On the other hand, if alphaMerge is set to false, the transparency is all there, except it overwrites whatever is beneath it (the pixels in drawBuffer) into transparent pixels. </p> <p>Just in case you need the code for drawBuffer as well:</p> <pre><code>drawBuffer = new BitmapData(bitmapData.width, bitmapData.height, true, 0); drawCanvas.graphics.beginBitmapFill(drawBuffer, null, false, true); drawCanvas.graphics.drawRect(0, 0, drawBuffer.width, drawBuffer.height); drawCanvas.graphics.endFill(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload