Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitmap too large to be uploaded into a texture (Universal Image Loader)

I have successfully used the same image before without problems. This behaviour just seems wrong, or at least weird to me.

  • UIL version: GitHub, commit Jan 28, 2014
  • Android Version: 4.3 (Galaxy Nexus)

My code and stack trace:

Application:

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).writeDebugLogs().build();
ImageLoader.getInstance().init(config);

Fragment:

String imageURI= "http://cdn.screenrant.com/wp-content/uploads/A-Stormtrooper-lost-in-the-desert.-2560x1080-Imgur.jpg";
DisplayImageOptions options = new DisplayImageOptions.Builder()
             .cacheInMemory(true)
             .cacheOnDisc(true).build();
ImageLoader.getInstance().displayImage(imageURI, imageView, options);

xml: (this is supposed to be the customTitle of an AlertDialog):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="64dp" >

    <ImageView
        android:id="@+id/clue_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/clue_title"
        android:layout_alignLeft="@+id/clue_title"
        android:layout_alignRight="@+id/clue_title"
        android:layout_alignTop="@+id/clue_title"
        android:layout_centerVertical="true"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        android:src="@drawable/trooper"
        tools:ignore="ContentDescription" />

    <TextView
        android:id="@+id/clue_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:background="#B3000000"
        android:ellipsize="end"
        android:gravity="start|center_vertical"
        android:minHeight="64dp"
        android:paddingBottom="5dp"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:paddingTop="5dp"
        android:text="@android:string/untitled"
        android:textAlignment="viewStart"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="@android:color/white" />

</RelativeLayout>

Stack trace:

02-03 00:11:48.343: D/ImageLoader(6701):    Start display image task [http://cdn.screenrant.com/wp-content/uploads/A-Stormtrooper-lost-in-the-desert.-2560x1080-Imgur.jpg_720x1184]
02-03 00:11:48.343: D/ImageLoader(6701):    Load image from disc cache [http://cdn.screenrant.com/wp-content/uploads/A-Stormtrooper-lost-in-the-desert.-2560x1080-Imgur.jpg_720x1184]
02-03 00:11:48.398: D/dalvikvm(6701):       GC_FOR_ALLOC freed 922K, 3% free 34681K/35664K, paused 51ms, total 51ms
02-03 00:11:48.476: I/dalvikvm-heap(6701):  Grow heap (frag case) to 49.525MB for 16384016-byte allocation
02-03 00:11:48.507: D/dalvikvm(6701):       GC_FOR_ALLOC freed 1K, 2% free 50679K/51668K, paused 32ms, total 32ms
02-03 00:11:48.875: D/ImageLoader(6701):    Cache image in memory [http://cdn.screenrant.com/wp-content/uploads/A-Stormtrooper-lost-in-the-desert.-2560x1080-Imgur.jpg_720x1184]
02-03 00:11:48.875: D/ImageLoader(6701):    Display image in ImageAware (loaded from DISC_CACHE) [http://cdn.screenrant.com/wp-content/uploads/A-Stormtrooper-lost-in-the-desert.-2560x1080-Imgur.jpg_720x1184]
02-03 00:11:48.882: W/OpenGLRenderer(6701): Bitmap too large to be uploaded into a texture (2560x1600, max=2048x2048)

If I'm not wrong, this image has been reduced to a size of 720x1184. If that is true, then why it is trying to use the original image 2560x1600?

I think this may be a bug, or am I missing something?

If this is not a bug, what can I do to solve it?

like image 392
gian1200 Avatar asked Dec 05 '25 10:12

gian1200


1 Answers

As I was encountering a similar problem, I came across this issue on GitHub. The problem seems to involve centerCrop, which wants to use an image larger than the destination before cropping it. I can't explain why the debug logs show it using a scaled-down image, but I can say that in my case, I got it working by adding the following to DisplayImageOptions:

    .imageScaleType(ImageScaleType.EXACTLY)

The GitHub issue also suggests that ScaleTypes of FIT_CENTER, FIT_XY, FIT_START, FIT_END, and CENTER_INSIDE will behave better.

like image 186
Brian Victor Avatar answered Dec 08 '25 00:12

Brian Victor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!