How to: 8-bit bitmap masks for soft edge creation
| Mon, 2005-08-22 12:40 | |
|
Hello!
According to Nokia's documentation, bitmap items can have two different types of masks: a 1-bit masks (hard masks) and an 8-bit masks (soft masks). An 8-bit mask is a greyscale image and allows creation of soft edges (anti-aliasing), and semi-transparency. Until now I have only used 1-bit greyscale (black) masks, that I painted in the simplier way, by using BitBltMasked, this way: Code: CFbsBitmap* iBmp = new(ELeave)CFbsBitmap(); CFbsBitmap* iBmpMask = new(ELeave)CFbsBitmap(); User::LeaveIfError(iBmp->Load(pathToMbm, bmpindex));Â Â //path to mbm and index to the bitmap User::LeaveIfError(iBmpMask->Load(pathToMbm, maskindex));Â Â //path to mbm and index to the 1-bit mask //... creation of the screen gc iOffGc->SetBrushStyle(CGraphicsContext::ENullBrush); iOffGc->BitBltMasked(pointToDraw, iBmp, TRect(TPoint(0, 0), iBmp->SizeInPixels()), iBmpMask, ETrue); How can I use the way to mask bitmaps with 8-bit greyscale masks too? Some of my "rounded-shape" bitmaps look notched using the 1-bit mask only (some of the light-coloured pixels are lost from the mask), and it's rather ugly (as seen in the below image). I used them often in my grid-like menus in the way described in the picture below (bitblt with mask and coloured or white background). I could use rectangular bitmaps and alpha-blending on the non-white pixels (windows-style: icons view in windows explorer look) for the highlited ones, but it's a resource-eating process (and I have dozens of bitmaps in the same screen). Can anybody please help me with a clue (advices, ways-to-do, documentation links) or a fragment of source code related to this subject? Thanks in advance! |
|





