Hi,

I just updated my Nexus 7 to 4.2 and am having a few issues with my code:

1) BitmapFactory.decodeStream() seems to have started stripping alpha from 
(so far all of) my bitmaps - ie: replacing them with 0xff. Load code:

BitmapFactory.Options opts=new BitmapFactory.Options();
opts.inPreferredConfig=Bitmap.Config.ARGB_8888;   //added today - 'just in 
case'...never used to need it.
opts.inPurgeable=true;   //removing this doesn't help
Bitmap bitmap=BitmapFactory.decodeStream( in,null,opts );

I've written a custom hasAlpha to verify all alpha has really been set to 
0xff, and it has.

2) I'm getting crashes when uploading textures with 
GLES11.glTexSubImage2D(). The issues appears to be related to 
ByteBuffer.allocate() and put() - if I use a byte array instead and then 
wrap it using ByteBuffer.wrap() things seem to work. The crash is in 
tegra.so at glTexSubImage2D+0xsomething. Old, crashing code:

ByteBuffer buf=ByteBuffer.allocate( sz*3 );
for( int i=0;i<sz;++i ){
  int p=pixels[i];
  int r=(p>>16) & 255;
  int g=(p>>8) & 255;
  int b=p & 255;
  buf.put( (byte)r );
  buf.put( (byte)g );
  buf.put( (byte)b );
}
GLES11.glTexImage2D( 
GLES11.GL_TEXTURE_2D,0,GLES11.GL_RGB,twidth,theight,0,GLES11.GL_RGB,GLES11.GL_UNSIGNED_BYTE,null
 
);
GLES11.glTexSubImage2D( 
GLES11.GL_TEXTURE_2D,0,0,0,pwidth,pheight,GLES11.GL_RGB,GLES11.GL_UNSIGNED_BYTE,buf
 
);  //BAM!

...new, working code...

byte[] data=new byte[sz*3];
for( int i=0;i<sz;++i ){
  int p=pixels[i];
  int r=(p>>16) & 255;
  int g=(p>>8) & 255;
  int b=p & 255;
  data[i*3+0]=(byte)r;
  data[i*3+1]=(byte)g;
  data[i*3+2]=(byte)b;
}
ByteBuffer buf=ByteBuffer.wrap( data );
GLES11.glTexImage2D( 
GLES11.GL_TEXTURE_2D,0,GLES11.GL_RGB,twidth,theight,0,GLES11.GL_RGB,GLES11.GL_UNSIGNED_BYTE,null
 
);
GLES11.glTexSubImage2D( 
GLES11.GL_TEXTURE_2D,0,0,0,pwidth,pheight,GLES11.GL_RGB,GLES11.GL_UNSIGNED_BYTE,buf
 
);

This has all worked fine to date on Android 1.6 through 4.1, so I'm 
guessing 4.2 has some rough edges...?

Or am I missing something in the above code?

I can work around the ByteBuffer issue for now, but the bitmap alpha issue 
is a bit of a show stopper...

Bye,
Mark

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to