Can not display large GIF image

All your problems with Audio, Video and Images.

Can not display large GIF image

Postby muniraju » Wed Jul 15, 2009 9:14 am

I have following code to display a image

Code: Select all
public void setBackgroundImage(Uri uri) throws FileNotFoundException {
        InputStream is = null ;
        try {
            Bitmap bm;
            BitmapFactory.Options opt =  new BitmapFactory.Options();
            opt.inJustDecodeBounds = true;
            BitmapFactory.decodeStream(is, null, opt);
            opt.inSampleSize = 1;
            Display d;
                WindowManager wm = (WindowManager) getContext().getSystemService(
                        Context.WINDOW_SERVICE);
                d = wm.getDefaultDisplay();
                h = d.getHeight();
                w = d.getWidth();
            while ((opt.outWidth/opt.inSampleSize) > w ||
                            (opt.outHeight/opt.inSampleSize) > h ) {
                   opt.inSampleSize <<= 1;
             }
             opt.inJustDecodeBounds = false;
            is = getContext().getContentResolver().openInputStream(
                    uri);
            bm = BitmapFactory.decodeStream(is, null, opt);

            super.setImageBitmap(bm);
        } catch (IOException e) {
            if ( e instanceof FileNotFoundException){
                throw (FileNotFoundException)e;
            }else {
                Log.e("CompositeImage", "Failed to decode"
                    + e.toString());
            }
        }finally {
            if (null != is) {
                try {
                    is.close();
                } catch (Exception e) {
                    //Can't do anything
                }
            }
        }
    }



Above code is working fine for all jpeg, Png, and bmp images.

But is giving OutofMemoryException for Gif images of Size 5MB or more.

Has anybody seen this problem. Is there any solution to it?

Thanks,
With Regards /
muniraju
Freshman
Freshman
 
Posts: 5
Joined: Fri Nov 21, 2008 8:53 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 5 guests