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.view.View;

public class Main {
    public static Bitmap createScreenshot3(View view, int thumbnailWidth, int thumbnailHeight, int top) {
        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);
            //            final int left = view.getScrollX();
            //            final int top = view.getScrollY();
            c.translate(0, -top);
            //c.scale(0.65f, 0.65f, left, top);
            try {
                // draw webview may nullpoint
                view.draw(c);
            } catch (Exception e) {
            }
            return mCapture;
        }
        return null;
    }
}