Note that there are some explanatory texts on larger screens.

plurals
  1. POproblem merging two bitmapdata objects' alpha channels
    text
    copied!<p>i have the following situation:</p> <p>one drawing layer (graphics object with lineTo, etc.)</p> <p>one png with an alpha channel (supposed to serve only as a mask)</p> <p>now i want to be able to only draw lines within an area restricted by the png mask.</p> <p>i am trying like this:</p> <pre><code>var bitmapData:BitmapData = new BitmapData( 320, 320 ); bitmapData.draw( drawingLayer ); bitmapData.copyChannel( maskBitmapData, new Rectangle( 0, 0, 320, 320 ), new Point( 0, 0 ), BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA ); </code></pre> <p>now the borders get cut off fine, but i get a black background, since the drawing layer has an alpha between the drawn lines (and it should remain like this) and the mask bitmap has an alpha outside the shape. so naturally the mask's alpha replaces the drawing layer's.</p> <p>i tried it with merge, copyPixels and also with just setting the mask property on the drawing layer (i set everything to cacheAsBitmap) but to no avail.</p> <p>can someone help me here?</p> <p><strong>ADDITION:</strong></p> <p>when trying to use a mask i tried it with</p> <pre><code>&lt;s:BitmapImage id="mask" source="@Embed(source='...')" cacheAsBitmap="true" /&gt; </code></pre> <p>and also as</p> <pre><code>[Embed("...")] private const BodyMask:Class; var maskBitmap:Bitmap = new BodyMask(); </code></pre> <p>and assigned them to the mask property of a s:Group element (cacheAsBitmap=true) where the operations on the graphics object occured. i also tried reassigning the mask after each draw operation.</p> <p>is there maybe something wrong with that?</p>
 

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