Advanced UI/src/com/samples/toolkit/ui/decor/BitmapMask.java
/**
     * Apply the mask to the given bitmap
     *
     * @param targetBitmap this bitmaps ARGB data will be modified with the alpha data from the mask
     */
Apply the mask to the given bitmap
@param targetBitmap this bitmaps ARGB data will be modified with the alpha data from the mask
Apply the mask to the given bitmap @param targetBitmap this bitmaps ARGB data will be modified with the alpha data from the mask
public void applyMask( Bitmap targetBitmap ) 
    {
        int targetWidth  = targetBitmap.getWidth();
        int targetHeight = targetBitmap.getHeight();
        int[] bufferARGB = new int[ targetWidth ];
        int targetTop    = Math.min( _alphaTop,    targetHeight );
        int targetRight  = Math.min( _alphaRight,  targetWidth );
        int targetBottom = Math.min( _alphaBottom, targetHeight );
        int targetLeft   = Math.min( _alphaLeft,   targetWidth );
        int targetInsideBottomY = targetHeight - targetBottom;
        int targetInsideTopY = targetTop;
        int targetInsideRightX = targetWidth - targetRight;
        int targetInsideLeftX = targetLeft;
        int targetInsideWidth  = Math.max( targetInsideRightX  - targetInsideLeftX,  0 );
        int targetInsideHeight = Math.max( targetInsideBottomY - targetInsideTopY,   0 );
        if( _alphaInsideWidth > 0) {
            if( targetTop > 0 ) {
                drawTileMask( _alphaLeft, 0, _alphaInsideWidth, _alphaTop,  
                              targetLeft, 0, targetInsideWidth, targetTop, targetBitmap, bufferARGB );    
            }
            if( targetBottom > 0 ) {
                drawTileMask( _alphaLeft, _alphaHeight - _alphaBottom, _alphaInsideWidth, _alphaBottom, 
                              targetLeft, targetHeight - targetBottom, targetInsideWidth, targetBottom, targetBitmap, bufferARGB );    
            }
        }
        if( _alphaInsideHeight > 0 ) {
            if( targetLeft > 0 ) {
                drawTileMask( 0, _alphaTop, _alphaLeft, _alphaInsideHeight,  
                              0, targetTop, targetLeft, targetInsideHeight, targetBitmap, bufferARGB );    
            }
            if( targetRight > 0 ) {
                drawTileMask( _alphaWidth - _alphaRight, _alphaTop, _alphaRight, _alphaInsideHeight,  
                              targetWidth - targetRight, targetTop, targetRight, targetInsideHeight, targetBitmap, bufferARGB );    
            }
        }
        if( targetTop > 0 ) {
            if( targetLeft > 0) {
                drawCornerMask( 0, 0, _alphaLeft, _alphaTop,  
                                0, 0, targetBitmap );     top
            }
            if( targetRight > 0 ) {
                drawCornerMask( _alphaLeft + _alphaInsideWidth, 0, _alphaRight, _alphaTop,  
                                targetInsideRightX, 0, targetBitmap );  top
            }
        }
        if( targetBottom > 0 ) {
            if( targetLeft > 0 ) {
                drawCornerMask( 0, _alphaHeight - _alphaBottom, _alphaLeft, _alphaBottom, 
                                0, targetHeight - targetBottom, targetBitmap );  bottom
            }
            if( targetRight > 0 ) {
                drawCornerMask( _alphaWidth - _alphaRight, _alphaHeight - _alphaBottom, _alphaRight, _alphaBottom, 
                                targetWidth - targetRight, targetHeight - targetBottom, targetBitmap );  bottom
            }
        }
    }
public void applyMask ( Bitmap targetBitmap ) { int targetWidth = targetBitmap . getWidth ( ) ; int targetHeight = targetBitmap . getHeight ( ) ; int [ ] bufferARGB = new int [ targetWidth ] ; int targetTop = Math . min ( _alphaTop , targetHeight ) ; int targetRight = Math . min ( _alphaRight , targetWidth ) ; int targetBottom = Math . min ( _alphaBottom , targetHeight ) ; int targetLeft = Math . min ( _alphaLeft , targetWidth ) ; int targetInsideBottomY = targetHeight - targetBottom ; int targetInsideTopY = targetTop ; int targetInsideRightX = targetWidth - targetRight ; int targetInsideLeftX = targetLeft ; int targetInsideWidth = Math . max ( targetInsideRightX - targetInsideLeftX , 0 ) ; int targetInsideHeight = Math . max ( targetInsideBottomY - targetInsideTopY , 0 ) ; if ( _alphaInsideWidth > 0 ) { if ( targetTop > 0 ) { drawTileMask ( _alphaLeft , 0 , _alphaInsideWidth , _alphaTop , targetLeft , 0 , targetInsideWidth , targetTop , targetBitmap , bufferARGB ) ; } if ( targetBottom > 0 ) { drawTileMask ( _alphaLeft , _alphaHeight - _alphaBottom , _alphaInsideWidth , _alphaBottom , targetLeft , targetHeight - targetBottom , targetInsideWidth , targetBottom , targetBitmap , bufferARGB ) ; } } if ( _alphaInsideHeight > 0 ) { if ( targetLeft > 0 ) { drawTileMask ( 0 , _alphaTop , _alphaLeft , _alphaInsideHeight , 0 , targetTop , targetLeft , targetInsideHeight , targetBitmap , bufferARGB ) ; } if ( targetRight > 0 ) { drawTileMask ( _alphaWidth - _alphaRight , _alphaTop , _alphaRight , _alphaInsideHeight , targetWidth - targetRight , targetTop , targetRight , targetInsideHeight , targetBitmap , bufferARGB ) ; } } if ( targetTop > 0 ) { if ( targetLeft > 0 ) { drawCornerMask ( 0 , 0 , _alphaLeft , _alphaTop , 0 , 0 , targetBitmap ) ; } if ( targetRight > 0 ) { drawCornerMask ( _alphaLeft + _alphaInsideWidth , 0 , _alphaRight , _alphaTop , targetInsideRightX , 0 , targetBitmap ) ; } } if ( targetBottom > 0 ) { if ( targetLeft > 0 ) { drawCornerMask ( 0 , _alphaHeight - _alphaBottom , _alphaLeft , _alphaBottom , 0 , targetHeight - targetBottom , targetBitmap ) ; } if ( targetRight > 0 ) { drawCornerMask ( _alphaWidth - _alphaRight , _alphaHeight - _alphaBottom , _alphaRight , _alphaBottom , targetWidth - targetRight , targetHeight - targetBottom , targetBitmap ) ; } } }
Apply the mask to the given bitmap
 @param targetBitmap this bitmaps ARGB data will be modified with the alpha data from the mask
Apply the mask to the given bitmap @param targetBitmap this bitmaps ARGB data will be modified with the alpha data from the mask
// top // bottom // left // right // left top // right top // left bottom // right bottom