views:

235

answers:

2

Hi,

I am looking for a way I can do an opacity mask in Compact Framework?

+2  A: 

i don't think that the CF version of .Net supports opacity at all. Makes some sense too. Calculating opacity is a very expensive operation, one not well suited to underpowered devices.

That said, here is a possible workaround.

Paul Sasik
+1  A: 

You can roll your own opacity mask for a Bitmap by simply doing the pixel-by-pixel manipulations yourself. The super-slow way to do this would be to use the Bitmap's GetPixel and SetPixel methods, but a much faster way is to use the LockBits method. See:

http://www.bobpowell.net/lockingbits.htm

Depending on what exactly you're doing, Windows Mobile devices have a surprising amount of processing power for this sort of thing. Iterating through and processing the 76,800 pixels of a 320x240 Bitmap using LockBits takes just a few milliseconds (depending on how complex the "processing" is, of course). Opacity masking (presumably) involves just comparing two pixel values and possibly calculating a third, so this would be no problem.

MusiGenesis

related questions