Glide 4.11+ only
With Glide, I can do this and get a bitmap, which is awesome,
protected void onActivityResult(int requestCode, int resultCode, Intent tent){
super.onActivityResult(requestCode, resultCode, data);
Glide.with(this).asBitmap()
.load(tent.getData())
.apply(new RequestOptions().override(300, 400))
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap glideBitmap,
@Nullable Transition<? super Bitmap> transition) {
Log.i("c", "BAM! Just like that, a bitmap ...");
Awesome.
However, often I need an actual bite array,
I do this ..
protected void onActivityResult(int requestCode, int resultCode, Intent tent){
super.onActivityResult(requestCode, resultCode, data);
Glide.with(this).asBitmap()
.load(tent.getData())
.apply(new RequestOptions().override(300, 400))
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap glideBitmap,
@Nullable Transition<? super Bitmap> transition) {
// convert badly to a byte array...
ByteArrayOutputStream baos = new ByteArrayOutputStream();
glideBitmap.compress(Bitmap.CompressFormat.JPEG, 70, baos);
byte[] byteData = baos.toByteArray();
Log.i("c", "had to work for bytes :/ ...");
I assume real droid programmers laugh at me?
Is there a more direct way to get a byte array from Glide?
Use case - am sending this up to Firebase in the usual byteish way,
UploadTask uploadTask = storeRef.putBytes(byteData);
Maybe I am XY, can Glide actually return a stream? As you know to send to Firebase you need either a stream or byte data. If so, sorry for being a lame-ass ios dev.