Image ratio check at runtime (Performance issue) - android

66 views Asked by At

I have an image picker application that selects images from gallery. If the image doesn't have a particular width/height ratio I display a small warning symbol on top of the image.

In my XML View File I have two ImageView views. It is below:

view.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:padding="10dp" >

 <ImageView
        android:id="@+id/imgQueue"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:scaleType="centerCrop" />

<ImageView
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:id="@+id/wrongimagesign"
        android:src="@drawable/error"
        android:layout_alignTop="@+id/imgQueue"
        android:layout_alignRight="@+id/imgQueue"
        android:layout_alignEnd="@+id/imgQueue"
        android:visibility="invisible"/>

</RelativeLayout>

The images are displayed in a gridview so in my adapter i have this code:

ImageLoader.getInstance().displayImage("file://" + image.cardPath, imgQueue);

**Bitmap bitmap = ImageLoader.getInstance().loadImageSync("file://" + image.cardPath, Utility.displayImageOptions);**

wrongImageSign.setVisibility(imageRatioIsBad(bitmap) ? View.VISIBLE : View.INVISIBLE);

The problem is that since i am loading the bitmap the performance is very slow (it takes too long to load the image and display the warning sign). Is there a way to improve the performance.

0

There are 0 answers