kimjo2
1
i wanna help that Solution "Convert Android Bitmap or Android Canvas to JME3 Texture2D OR Image OR Picture
My Application Platform is Android Samsung Galaxy Note3 .
i already know about that Converting AndroidBitmap to Image with AssetInfo.
But i wanna create Dynamic Bitmap and directly convert it to JME3 Format (e.g Texture2D, Image, Picture -> i want this format attach to guiNode)
so i cannot have AssetInfo for Dynamic Bitmap
Help please~
kimjo2
2
I solved the problem by using ARGB_8888 AND RGBA8
Before i used ARGB_4444 and then that cannot be convert completly
so i change the Image Type.
But still i wonder that why is converting ARGB_8888 AND RGBA8 is successful.
i think these Type are not same.
[java]
//Create an empty, mutable bitmap
Bitmap bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
// clear background
bitmap.eraseColor(0);
//draw the text centered
//get a canvas to paint over the bitmap
Canvas canvas = new Canvas(bitmap);
canvas.drawColor(color.transparent);
canvas.drawText(name, 0,bitmap.getHeight(), textPaint);
//Flip Vertical
Matrix matrix = new Matrix();
matrix.preScale(1.0f, -1.0f);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmapWidth, bitmapHeight, matrix, true);
int cont = bitmap.getByteCount();
ByteBuffer buffer = ByteBuffer.allocate(cont);
bitmap.copyPixelsToBuffer(buffer);
Image image = new Image(Format.RGBA8, bitmapWidth, bitmapHeight, buffer, null);
image.setData(buffer);
// release bitmap object
bitmap.recycle();
return image;
[/java]