Advanced UI/src/com/samples/toolkit/ui/decor/BitmapMask.java
/**
     * Apply a portion of the mask to the destination area. Tile if destination area is larger than source area
     */
Apply a portion of the mask to the destination area. Tile if destination area is larger than source area
Apply a portion of the mask to the destination area . Tile if destination area is larger than source area
private void drawTileMask( int sourceX, int sourceY, int sourceWidth, int sourceHeight, 
                               int destX,   int destY,   int destWidth,   int destHeight, 
                               Bitmap targetBitmap, int[] bufferARGB )
    {
        int sourceOffsetStart = sourceY * _alphaWidth + sourceX;
        int sourceOffsetMax   = ( sourceY + sourceHeight ) + _alphaWidth;
        int sourceOffset = sourceOffsetStart;
        for( int y=0; y<destHeight; y++, destY++ ) {
            targetBitmap.getARGB( bufferARGB, 0, destWidth, destX, destY, destWidth, 1 );
            for( int x=0; x<destWidth; x++ ) {
                bufferARGB[ x ] = ( bufferARGB[ x ] & 0x00ffffff ) | _alphaARGB[ sourceOffset + x % sourceWidth ];
            }
            targetBitmap.setARGB( bufferARGB, 0, destWidth, destX, destY, destWidth, 1 );
            sourceOffset += _alphaWidth;
            if( sourceOffset >= sourceOffsetMax ) {
                sourceOffset = sourceOffsetStart;
            }
        }
    }
private void drawTileMask ( int sourceX , int sourceY , int sourceWidth , int sourceHeight , int destX , int destY , int destWidth , int destHeight , Bitmap targetBitmap , int [ ] bufferARGB ) { int sourceOffsetStart = sourceY * _alphaWidth + sourceX ; int sourceOffsetMax = ( sourceY + sourceHeight ) + _alphaWidth ; int sourceOffset = sourceOffsetStart ; for ( int y = 0 ; y < destHeight ; y ++ , destY ++ ) { targetBitmap . getARGB ( bufferARGB , 0 , destWidth , destX , destY , destWidth , 1 ) ; for ( int x = 0 ; x < destWidth ; x ++ ) { bufferARGB [ x ] = ( bufferARGB [ x ] & 0x00ffffff ) | _alphaARGB [ sourceOffset + x % sourceWidth ] ; } targetBitmap . setARGB ( bufferARGB , 0 , destWidth , destX , destY , destWidth , 1 ) ; sourceOffset += _alphaWidth ; if ( sourceOffset >= sourceOffsetMax ) { sourceOffset = sourceOffsetStart ; } } }
Apply a portion of the mask to the destination area.
Apply a portion of the mask to the destination area .