Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d585066

Browse files
authored
Update getting Bitmap from ImageView (firebase#21)
2 parents 1669b01 + 619e054 commit d585066

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

storage/app/src/main/java/com/google/firebase/referencecode/storage/StorageActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.firebase.referencecode.storage;
1818

1919
import android.graphics.Bitmap;
20+
import android.graphics.drawable.BitmapDrawable;
2021
import android.net.Uri;
2122
import android.os.Bundle;
2223
import android.support.annotation.NonNull;
@@ -168,7 +169,7 @@ private void includesForUploadFiles() throws FileNotFoundException {
168169
// Get the data from an ImageView as bytes
169170
imageView.setDrawingCacheEnabled(true);
170171
imageView.buildDrawingCache();
171-
Bitmap bitmap = imageView.getDrawingCache();
172+
Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
172173
ByteArrayOutputStream baos = new ByteArrayOutputStream();
173174
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
174175
byte[] data = baos.toByteArray();

0 commit comments

Comments
 (0)