decode Sampled Bitmap From Data - Android Graphics

Android examples for Graphics:Bitmap Read

Description

decode Sampled Bitmap From Data

Demo Code


//package com.java2s;

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

public class Main {
    public static Bitmap decodeSampledBitmapFromData(byte[] data) {

        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeByteArray(data, 0, data.length, options);
        options.inSampleSize = 1; // saved image will be one half the width and

        options.inJustDecodeBounds = false;
        return BitmapFactory.decodeByteArray(data, 0, data.length, options);
    }//from   w  w  w.  ja  v  a2s  . com
}

Related Tutorials