Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.IOException;

import android.content.Context;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;

import android.graphics.Paint;

public class Main {
    public static Bitmap getRemoveBitmap(Context context, Bitmap bitmap) {
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        Bitmap bitmap1;
        try {
            Bitmap bitmap2 = BitmapFactory.decodeStream(context.getAssets().open("remove@2x.png"));
            bitmap1 = Bitmap.createBitmap(bitmap.getWidth() + bitmap2.getWidth() / 2,
                    bitmap.getHeight() + bitmap2.getHeight() / 2, android.graphics.Bitmap.Config.ARGB_8888);
            Canvas canvas1 = new Canvas(bitmap1);
            canvas1.drawARGB(0, 0, 0, 0);
            canvas1.drawBitmap(bitmap, bitmap2.getWidth() / 2, bitmap2.getHeight() / 2, paint);
            bitmap.recycle();
            canvas1.drawBitmap(bitmap2, 0.0F, 0.0F, paint);
            bitmap2.recycle();
        } catch (IOException ioexception) {
            ioexception.printStackTrace();
            bitmap1 = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(),
                    android.graphics.Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmap1);
            canvas.drawARGB(0, 0, 0, 0);
            canvas.drawBitmap(bitmap, 0.0F, 0.0F, paint);
            bitmap.recycle();
        }
        return bitmap1;
    }
}