Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have looked into this myself a year ago, and quickly resorted to using a black layer with transparent parts. It suited my then needs. But what you want is possible..</p> <p>You want to couple one TBitmapLayer to another and consider it its mask. I want to avoid these references however (and its potential problems and Graphics32 rework) and see this only as a last resort.</p> <p>There is a way to do without a dedicated TBitmapLayer, using your own pixel combiner. But it doesn't know about TBitmapLayers and its XY pixels.</p> <p>To proper occlude (or leave out) parts of a <code>TBitmapLayer</code> while drawing to screen, you could use create a method of <a href="http://graphics32.org/documentation/Docs/Units/GR32/Types/TPixelCombineEvent.htm" rel="nofollow">type <code>TPixelCombineEvent</code></a> and assigning this as its <code>OnPixelCombine</code> and setting <code>TBitmapLayer.DrawMode</code> to <code>dmCustom</code>.</p> <p>Inside that <code>TPixelCombineEvent</code> method you decide what pixels result given the background <code>B</code> and the foreground <code>F</code> given the current <code>M</code> master alpha.</p> <pre><code>procedure TMyObj.MyPixCombine(F: TColor32; var B: TColor32; M: TColor32); begin if not PseudoThisPixelShouldBeMasked then B := F; // ugly and aliased end; </code></pre> <p>Problem here is, that (the pseudo code) PseudoThisPixelShouldBeMasked doesn't really know what pixel this concerns and whether it is inside a mask. So you'd have to extract that value from a component of <code>F</code>, such as its Alpha value.</p> <p>Back then i opted for the quite fast <code>B := ColorMin(F,B);</code> where F is black or white. This layer is on top always and results in black instead of transparent masks however. This because any rendering to the <code>TBitmapLayer</code> would destroy the mask data and i need to reapply it. Using a <code>TByteMap</code> however as suggested below (who downvoted that?) by iamjoosy might be interesting, perhaps that performance penalty turns out negligible.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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