Picasso to load byte array

I need to load a bitmap, i.e. in the file system, into an array of bytes in order to load it, but it should be:

  • Changed to 500x500 and in bytes [].
  • Asynchronous

I can do it with a slip

Glide.with(context) .load("/user/profile/photo/path") .asBitmap() .toBytes() .centerCrop() .into(new SimpleTarget<byte[]>(250, 250) { @Override public void onResourceReady(byte[] data, GlideAnimation anim) { // Post your bytes to a background thread and upload them here. } }); 

but I don’t want to include it just for that. Any way to do this with picasso?

+5
source share
1 answer

Try this solution.

 Bitmap bmp = intent.getExtras().get("data"); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] byteArray = stream.toByteArray(); 
0
source

All Articles