[SOLVED] Pass bitmap from android camera into haxe app

I wrote small extension who makes photo on android device.
I use Intent with action MediaStore.ACTION_IMAGE_CAPTURE. Then i receive Bitmap in onActivityResult callback. How can i pass this object to my haxe application as Bitmap or BitmapData or other convertable type for Haxe? If i just call callback with Dynamic type parameter i receive type Object in Haxe handler.

Maybe pass a byte array first, then fill the bytes, or perhaps it could be done as an array?

I converted the resulting image to base64 string. Java

Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
imageBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
String decoded = Base64.encodeToString(byteArray, Base64.DEFAULT);
_callback.call("onCallback", new Object[]{ decoded });

And receive this string in my haxe callback… And… I have no ideas abot next actions… :pokerface:

can you use the callback with the string value, rather than wrapping it in an object?

It’s actually an object array (of length 1), not a plain object. Also, I thought using the object array was required to avoid crashes…

Nevermind… Object is superclass of String. Passing String as Object works correctly. Callback works fine. I receive base64 string from android Extension to my callback. How can i convert base64 String to Bitmap with openfl tools?

I found solution: in android callback contains uri of created image. I just pass image url to haxe app from android…

// Android
public boolean onActivityResult (int requestCode, int resultCode, Intent data) {
	 _takePhotoCallback.call("takePhotoCallback", new Object[]{ getRealPathFromURI(Extension.mainContext, data.getData()) });

getRealPathFromURI() method realization

// Haxe
public function takePhotoCallback(result:Dynamic) {
	var loader:Loader = new Loader();
	loader.load(new URLRequest(result));