Code example for BitmapShader

0
		mDrawingRect = new Rect(0, 0, w, h);
 
		final Bitmap mask = convertToAlphaMask(Bitmap.createScaledBitmap(mMask,
				w, h, false));
		mPaint.setShader(new BitmapShader(mask, Shader.TileMode.CLAMP,
				Shader.TileMode.CLAMP));
 
		mBackground = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
		mBackgroundCanvas.setBitmap(mBackground);
	} 
 
	@Override 
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
 
		final long time = SystemClock.uptimeMillis();
		final int diff = (int) (time - mLastChange);
		if (time - mLastChange > mDuration) {
			mDirection = !mDirection;
			mLastChange = time;
		}