Bogdan Daniel Bogdan Daniel - 1 month ago 20
Android Question

Fresco - Bitmap too large to be uploaded into a texture

I'm trying to display an Image from the gallery into a SimpleDraweeView. I don't know if this is the way to do it, but what I'm doing is going into the gallery, selecting the image and getting the image path. After that I use

to set the image into that SimpleDraweeView (that's the type of galleryImage). Unfortunately I get
Bitmap too large to be uploaded into a texture (4128x2322, max=4096x4096)

Here is my code that opens the gallery and returns the imagePath.

public void loadImagefromGallery(View view) {
// Create intent to Open Image applications like Gallery, Google Photos
Intent galleryIntent = new Intent(Intent.ACTION_PICK,
// Start the Intent
startActivityForResult(galleryIntent, RESULT_LOAD_IMG);

// When Image is selected from Gallery
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try {
// When an Image is picked
if (requestCode == RESULT_LOAD_IMG && resultCode == RESULT_OK
&& null != data) {
// Get the Image from data

Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};

// Get the cursor
Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
// Move to first row

int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
imgPath = cursor.getString(columnIndex);
Toast.makeText(this, imgPath,
String url = "file://" + imgPath;

} else {
Toast.makeText(this, "You haven't picked Image",
} catch (Exception e) {
Toast.makeText(this, "Something went wrong", Toast.LENGTH_LONG)



ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
.setResizeOptions(new ResizeOptions(galleryImage.getLayoutParams().width, galleryImage.getLayoutParams().height));

DraweeController controller = Fresco.newDraweeControllerBuilder()



You will need to use an ImageRequestBuilder and a Drawee Controller to set the resize options so that the images that are too large (over 2048 in either width or height) get resized before being put into a texture. Like this:

ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri))
            .setResizeOptions(new ResizeOptions(getLayoutParams().width, getLayoutParams().height));

    DraweeController controller = Fresco.newDraweeControllerBuilder()