0

I'am trying convert Byte Array to Bitmap to show in imageView in android, I am taking byte data from method but When I run the below function,I am taking null value of Bitmap, how can I take bitmap value from byte[] array

 private CameraProxy.CameraDataCallBack callBack = new CameraProxy.CameraDataCallBack() {

        @Override
        public void onDataBack(byte[] data, long length) {
            // TODO Auto-generated method stub
            Log.i(TAG, "length . " + length);

            Log.i("data",""+data);

            Bitmap bitmap = BitmapFactory.decodeByteArray(data,0,data.length);
            im.setImageBitmap(bitmap);




        }
    };
SamHoque
  • 2,978
  • 2
  • 13
  • 43
Rıdvan
  • 51
  • 7

1 Answers1

0

These code works for me.

            bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(),                       
            selectedImage);

            img = findViewById(R.id.imageView);

            //img.setImageBitmap(bitmap);

            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
            byteArray = stream.toByteArray();