Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.graphics.Bitmap;

import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuffXfermode;

public class Main {
    public static Bitmap createReflectionImageWithOrigin(Bitmap bitmap) {
        int i = bitmap.getWidth();
        int j = bitmap.getHeight();
        Matrix matrix = new Matrix();
        matrix.preScale(1.0F, -1F);
        Bitmap bitmap1 = Bitmap.createBitmap(bitmap, 0, j / 2, i, j / 2, matrix, false);
        Bitmap bitmap2 = Bitmap.createBitmap(i, j + j / 2, android.graphics.Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap2);
        canvas.drawBitmap(bitmap, 0.0F, 0.0F, null);
        Paint paint = new Paint();
        canvas.drawRect(0.0F, j, i, j + 4, paint);
        canvas.drawBitmap(bitmap1, 0.0F, j + 4, null);
        Paint paint1 = new Paint();
        paint1.setShader(new LinearGradient(0.0F, bitmap.getHeight(), 0.0F, 4 + bitmap2.getHeight(), 0x70ffffff,
                0xffffff, android.graphics.Shader.TileMode.CLAMP));
        paint1.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.DST_IN));
        canvas.drawRect(0.0F, j, i, 4 + bitmap2.getHeight(), paint1);
        return bitmap2;
    }
}