Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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