create Reflective image - Android Media

Android examples for Media:Picture

Description

create Reflective image

Demo Code


//package com.java2s;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;

import android.graphics.Canvas;
import android.graphics.Color;

import android.graphics.Paint;

import android.graphics.Rect;
import android.graphics.RectF;

public class Main {

    public static Bitmap createReflectiveimage(Bitmap bitmap) {
        int height = bitmap.getHeight();
        int width = bitmap.getWidth();
        Bitmap bitmapWithReflection = Bitmap.createBitmap(width, height,
                Config.ARGB_8888);/*from w ww.  j av  a  2  s .  co m*/
        Canvas canvas = new Canvas(bitmapWithReflection);
        canvas.drawBitmap(bitmap, 0, 0, null);
        Paint paint = new Paint();
        paint.setColor(Color.WHITE);
        paint.setAlpha(15);
        int w = width / 2;
        int h = height / 3;
        final Rect rect = new Rect(-w, -2 * h, 3 * w, h);
        final RectF rectF = new RectF(rect);
        canvas.drawOval(rectF, paint);
        return bitmapWithReflection;
    }
}

Related Tutorials