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.Paint;

import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;

import android.view.View;

public class Main {
    public static Bitmap createScreenshot4(View view, int thumbnailWidth, int thumbnailHeight) {
        if (view != null) {
            Bitmap mCapture;
            try {
                mCapture = Bitmap.createBitmap(thumbnailWidth, thumbnailHeight, Bitmap.Config.RGB_565);
            } catch (OutOfMemoryError e) {
                return null;
            }
            Canvas c = new Canvas(mCapture);
            Paint transPainter = new Paint();
            transPainter.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
            c.drawRect(0, 0, mCapture.getWidth(), mCapture.getHeight(), transPainter);
            try {
                view.draw(c);
            } catch (Exception e) {
            }
            return mCapture;
        }
        return null;
    }
}