Font have transparent and gray color.
My source code:
Using java Syntax Highlighting
- Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.title);
- int []pixels = new int[symbol_width*symbol_height*4];
- for(int i=0; i<string.length; i++) {
- char ch = string.charAt(i);
- for(int i=0; i<gliphs.length; i++){
- if(gliphs[i]==ch) {
- begin = gliph_coords[i][0]*bmp_width;
- end = gliph_coords[i][1]*bmp_width;
- break;
- }
- }
- ...
- bmp.getPixels(pixels, 0, symbol_width, (int)begin, 0, symbol_width, symbol_height);
- IntBuffer ibuff = IntBuffer.wrap(pixels);
- gl.glBindTexture(GL10.GL_TEXTURE_2D, name);
- gl.glTexSubImage2D(GL10.GL_TEXTURE_2D, 0, Dx, Dy, symbol_width, symbol_height, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, ibuff);
- Dx+=end;
- }
- ...
- gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
After running this code on emulator and real device, gray color is black
If I use:
1)
Using java Syntax Highlighting
- int []pixels = new int[bmp1.getWidth()*bmp1.getHeight()];
- bmp1.getPixels(pixels, 0, bmp1.getWidth(), 0, 0, bmp1.getWidth(), bmp1.getHeight());
- Bitmap bmp2 = Bitmap.createBitmap(pixels, bmp1.getWidth(), bmp1.getHeight(), Config.RGB_565);
- gl.glBindTexture(GL10.GL_TEXTURE_2D, name);
- GLUtils.texSubImage2D(GL10.GL_TEXTURE_2D, 0, 0, 0, bmp2, GL10.GL_RGB, GL10.GL_UNSIGNED_SHORT_5_6_5);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
I get result(see screenshot1.png)
2)
Using java Syntax Highlighting
- Bitmap bmp1 = BitmapFactory.decodeResource(context.getResources(), R.drawable.title);
- // // Convert ARGB -> RGBA
- ByteBuffer bb = ByteBuffer.allocateDirect(bmp1.getHeight()
- * bmp1.getWidth() * 4);
- bb.order(ByteOrder.BIG_ENDIAN);
- IntBuffer ib = bb.asIntBuffer();
- for (int y=bmp1.getHeight()-1;y>-1;y--)
- for (int x=0;x<bmp1.getWidth();x++) {
- int pix = bmp1.getPixel(x,bmp1.getHeight()-y-1);
- // Convert ARGB -> RGBA
- @SuppressWarnings("unused")
- byte alpha = (byte)((pix >> 24)&0xFF);
- byte red = (byte)((pix >> 16)&0xFF);
- byte green = (byte) ((pix >> <img src="http://www.anddev.org/images/smilies/cool.png" alt="8)" title="Cool" />&0xFF);
- byte blue = (byte)((pix)&0xFF);
- // It seems like alpha is currently broken in Android...
- ib.put(red << 24 | green << 16 | blue << 8 | 0xFF);//255-alpha);
- }
- bb.position(0);
- gl.glBindTexture(GL10.GL_TEXTURE_2D, name);
- gl.glTexSubImage2D(GL10.GL_TEXTURE_2D, 0, 0, 0, bmp1.getWidth(), bmp1.getHeight(), GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, bb);
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
I get result(see screenshot2.png)
3) If I use:
Using java Syntax Highlighting
- for (int y=bmp.getHeight()-1;y>-1;y--)
- for (int x=0;x<bmp.getWidth();x++) {
- int pix = bmp.getPixel(x,bmp.getHeight()-y-1);
- // Convert ARGB -> RGBA
- @SuppressWarnings("unused")
- int alpha = ((pix >> 24)&0xFF);
- int red = ((pix >> 16)&0xFF);
- int green = ((pix >> <img src="http://www.anddev.org/images/smilies/cool.png" alt="8)" title="Cool" />&0xFF);
- int blue = ((pix)&0xFF);
- ib.put(red << 24 | green << 16 | blue << 8 | 255-alpha);
- }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
I get result(see screenshot3.png)
How can I fix this?
Thank you.
[mod]This is not a tutorial, why post it here?MOVED

