Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//  License: https://servicestack.net/bsd-license.txt

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;

public class Main {
    public static Bitmap readBitmap(HttpURLConnection response) {
        try {
            return readBitmap(response.getInputStream());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static Bitmap readBitmap(InputStream stream) {
        return BitmapFactory.decodeStream(stream);
    }

    public static Bitmap readBitmap(byte[] bytes) {
        return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
    }
}