Image problem

All your problems with Audio, Video and Images.

Image problem

Postby Johan » Tue May 19, 2009 2:47 pm

Hello,

I've a listview with +-250 rows (It's not really usefull, I think, but I had to do it this way). Each row consists of a different logo (in an imageview) and a title (in a textview). Until now I stored my logos in the res/drawable directory, and used the ID's to set the logos:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public View getView(final int position, View convertView,
  3.  
  4.                                 ViewGroup parent) {
  5.  
  6. ...
  7.  
  8. ImageView logo = (ImageView) tableRow
  9.  
  10.                                         .findViewById(R.id.list_row_logo);
  11.  
  12. logo.setImageResource(R.drawable.logo1);
  13.  
  14. ...
  15.  
  16. }
  17.  
  18.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

This works fine.
But now I have to download the logos from a webserver at runtime (because the content of the list isn't always the same) and store them.
So first I downloaded the image to the file directory, then created a drawable like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  Drawable d = Drawable.createFromPath(/data/data/..../files/ +
  3.  
  4.                                                   DataProvider.getInstance().getChannelByPosition(position).getChannelLogo());
  5.  
  6.  logo.setImageDrawable(d);
  7.  
  8.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

It shows the logos, but after a while (when I'm scrolling through the list) it gives an error:

Code: Select all
05-19 15:18:52.687: ERROR/dalvikvm-heap(9361): 42976-byte external allocation too large for this process.
05-19 15:18:52.687: ERROR/(9361): VM won't let us allocate 42976 bytes

So it looks like this is not the best way for doing this.
I also tried
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Bitmap bm = BitmapFactory.decodeFile(....);
  3.  
  4. logo.setImageBitmap(bm);
  5.  
  6.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4

this gives an OutOfMemory Exception (maybe I'll ve to add bm.recycle(); somewhere, but I don't know where)

Has someone an idea to solve my problem?

thanks
Johan
Freshman
Freshman
 
Posts: 7
Joined: Fri Feb 20, 2009 3:30 pm

Top

Postby Johan » Tue May 26, 2009 8:28 am

Anyone?
Johan
Freshman
Freshman
 
Posts: 7
Joined: Fri Feb 20, 2009 3:30 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 14 guests