Re: [android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread Chad Ata
Hi Joao, Cool, that's similar to what we've done. I think I'm going to ignore this problem until I get a few more bug reports - hopefully with more details. Thanks for helping out! -Chad On Thu, Sep 29, 2011 at 2:44 PM, Joao Braga wrote: > I see... > Well I don't know the style of your game a

Re: [android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread Joao Braga
I see... Well I don't know the style of your game and how it was developed. I'm developing a game engine myself and for the memory issue, we are building a Memory Manager that knows exactly when to allocate, when to free and when to reuse an object of the game. The result of it is less load time a

Re: [android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread Chad Ata
On some phones, like the small screen Motorola's, we've found that we really push the memory limitations. If a user has a lot of junk of the screen (in-game), then they risk OOM exception. We are aggressively calling bitmap.recycle() whenever an image is no longer being used - and that has been rea

Re: [android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread Joao Braga
I see, but it souldn't be a problem since the phones have enough memory to load a image like that. I'm just talking about the image, I don't know how the rest of your engine is managing the memory. But you said something about 200k sessions...how this sessions work? The clients connect to a server

Re: [android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread Chad Ata
It's a game. At a certain part it loads a large transparent png - about 900x300 or something like that. This issue seems to happen only with the larger images, which is why I was thinking it had to do with possible low memory situation. -Chad On Thu, Sep 29, 2011 at 2:05 PM, Joao Braga wrote:

Re: [android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread Chad Ata
Hi Joao, Yes that code works for me - actually I was already doing something similar in a different part of my code. Unfortunately, since it's such a rare bug I won't know if it really fixed the problem until I deploy it to my users. -Chad On Thu, Sep 29, 2011 at 2:01 PM, Joao Braga wrote: >

Re: [android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread Joao Braga
It's an architectural problem. What's your application about? What does it do? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send em

Re: [android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread Chad Ata
Thanks for the responses guys, Just a note: My code always works when I test it. The bug is happening once every 200k sessions (as reported via Android Market). -Chad On Thu, Sep 29, 2011 at 1:58 PM, Chad Ata wrote: > Thanks for the response Joao, > > Interesting. Do you think there's a bug in

Re: [android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread Joao Braga
Maybe, but I can't tell since I never used it. Did the code work for you? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email t

Re: [android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread Joao Braga
Can you get to your resource through R.drawable. ? You can get errors if you store pictures with invalid names for the resources (spaces, special chars, numbers etc). -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, s

Re: [android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread Chad Ata
Thanks for the response Joao, Interesting. Do you think there's a bug in the decodeResource() when using BitmapFactory.Options? -Chad On Thu, Sep 29, 2011 at 1:49 PM, Joao Braga wrote: > Try this: > > Bitmap bitmap; > bitmap = BitmapFactory.decodeResource(res, R.drawable.image); > bitmap = Bit

Re: [android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread Joao Braga
ops, I forgot the resources: Bitmap bitmap; bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.image); bitmap = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth(), bitmap.getHeight(), false); //if you want to make it scaleble Note: If you are creating this bitmap from the class o

[android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread jtoolsdev
I got a null pointer when my PNG file was incorrectly saved. Since I was developing on Linux, I loaded it into GIMP and saved it back out and it loaded. So you might check using one of the image files supplied in the SDK. -- You received this message because you are subscribed to the Googl

Re: [android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread Joao Braga
Try this: Bitmap bitmap; bitmap = BitmapFactory.decodeResource(res, R.drawable.image); bitmap = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth(), bitmap.getHeight(), false); //if you want to make it scaleble -- You received this message because you are subscribed to the Google Groups "Android

[android-developers] Re: BitmapFactory.decodeResource returning null sometimes for local resource

2011-09-29 Thread Sheado
Hi Joao, Here it is: BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inScaled = false; Bitmap b = BitmapFactory.decodeResource( context.getResources(), R.drawable.testImage, opts ); b.getWidth(); // < NPE This always works for me when I test it. Thanks, Chad On Sep 29, 1