Android: Shader behave different in 'onDraw(canvas)' and 'new Canvas(bitmap)'
<p>I am trying to create a reflection shadow and found an issue.</p>

<p>Please find the below code in my custom view:</p>

<pre><code>@Override
protected void onDraw(Canvas canvas) {
    //prepare
    canvas.drawColor(Color.GRAY);
    Bitmap source = BitmapFactory.decodeResource(getResources(), R.drawable.icon);

    //First Column
    canvas.drawBitmap(source, 0, 0, new Paint());

    //2nd Column
    canvas.drawBitmap(source, source.getWidth(), 0, new Paint());

    //Reflection
    Matrix matrix = new Matrix();
    matrix.preScale(1.0f, -1.0f);
    matrix.postTranslate(source.getWidth(), source.getHeight()*2);
    canvas.drawBitmap(source, matrix, new Paint());

    Paint paint2 = new Paint();
    LinearGradient shader = new LinearGradient(
            source.getWidth()*3/2, 
            source.getHeight(),
            source.getWidth()*3/2,
            source.getHeight()*2,
            0x7FFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
    paint2.setShader(shader);
    paint2.setXfermode(new PorterDuffXfermode(
            android.graphics.PorterDuff.Mode.DST_IN));
    canvas.drawRect(
            source.getWidth(), 
            source.getHeight(),
            source.getWidth()*2,
            source.getHeight()*2,
            paint2);

    //3rd Column
    Bitmap bitmap = Bitmap.createBitmap(source.getWidth(), source.getHeight()*2, Config.ARGB_8888);
    Canvas canvas2 = new Canvas(bitmap);
    canvas2.drawBitmap(source, 0, 0,  new Paint());
    matrix = new Matrix();
    matrix.preScale(1.0f, -1.0f);
    matrix.postTranslate(0, source.getHeight()*2);
    canvas2.drawBitmap(source, matrix, new Paint());


    paint2 = new Paint();
    shader = new LinearGradient(
            source.getWidth()*1/2, 
            source.getHeight(),
            source.getWidth()*1/2,
            source.getHeight()*2,
            0x7FFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
    paint2.setShader(shader);
    paint2.setXfermode(new PorterDuffXfermode(
            android.graphics.PorterDuff.Mode.DST_IN));
    canvas2.drawRect(
            0, 
            source.getHeight(),
            source.getWidth(),
            source.getHeight()*2,
            paint2);

    canvas.drawBitmap(bitmap, source.getWidth()*2,0, new Paint());
}
</code></pre>

<p>I am doing same in canvas (which I got from <code>onDraw(canvas)</code>) and canvas2 (which created using <code>new Canvas(bitmap)</code>)</p>

<p>But, both drawing different shader effect as follows:
<img src="http://i.stack.imgur.com/v4kWv.png" alt="different shader effect"></p>

<p>Why are the shader effects different?</p>
