Android Byte Array to Bitmap Convert decodeSampledBitmapFromData(byte[] data)

Here you can find the source of decodeSampledBitmapFromData(byte[] data)

Description

decode Sampled Bitmap From Data

License

Apache License

Declaration

public static Bitmap decodeSampledBitmapFromData(byte[] data) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

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

        // First decode with inJustDecodeBounds=true to check dimensions
        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);
    }//  ww w . ja  v  a  2s .c o  m
}

Related

  1. byteToBitmap(byte[] iconByte)
  2. ByteStringToBitmap(ByteString bytes)
  3. bytes2Bimap(byte[] b)
  4. bytes2Bimap(byte[] bytes)