Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Android Image Loading


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 styuR   Members   -  Reputation: 100

Like
0Likes
Like

Posted 29 April 2012 - 10:06 PM

I'm having issues with the way that I'm loading my images in Android, this is the way I'm doing it just now.


try{
AssetManager assetManager = context.getAssets();
inputStream = assetManager.open("blackcat.png");
cat = BitmapFactory.decodeStream(inputStream);
inputStream.close();

inputStream = assetManager.open("Jellyfish1.png");
jellyfish = BitmapFactory.decodeStream(inputStream);
inputStream.close();

inputStream = assetManager.open("/Dog.png");
bigdog = BitmapFactory.decodeStream(inputStream);
inputStream.close();

inputStream = assetManager.open("exit.png");
exitTile = BitmapFactory.decodeStream(inputStream);
inputStream.close();

inputStream = assetManager.open("kitchen.png");
background = BitmapFactory.decodeStream(inputStream);
inputStream.close();

inputStream = assetManager.open("endscreen.png");
gameover = BitmapFactory.decodeStream(inputStream);
inputStream.close();
}catch(IOException ex){}

Any help would be massively appreciated as I'm pretty stuck for what to do now.

Edited by styuR, 29 April 2012 - 10:07 PM.


Sponsor:

#2 Zael   Members   -  Reputation: 154

Like
0Likes
Like

Posted 30 April 2012 - 09:50 AM

Is there any reason you are loading them from assets instead of resources? As I recall loading them from resources is slightly easier.

#3 styuR   Members   -  Reputation: 100

Like
0Likes
Like

Posted 30 April 2012 - 06:41 PM

Nope, no reason, I'm pretty inexperienced with this haha.

#4 Mihai Moldovan   Members   -  Reputation: 127

Like
0Likes
Like

Posted 30 April 2012 - 06:43 PM

If you can use resources, just load it like this:

Drawable drawable = getResources().getDrawable(R.drawable.whateveryourimageiscalled);





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS