GalleryPicker

Monkey Targets Forums/Android/GalleryPicker

Ironstorm(Posted 2014) [#1]
Hey guys.

Currently I'm working on an ImagePicker. With this one you will be able to pick a image from the gallery and load it into your project.
Well, first of all, it works. Basically...

My problem is that if you browse to a directory and want to go back the imagepicker closes immediately and throw out an "RESULT_CANCELED" in "onActivityResult".
Here is a screenshot which describes my problem. If I press the button in the upper left corner or the hardware-back-button the imagepicker will be closed.

- Solved -
The second problem is the size of the images taken with the camera. If I try to load such a large image monkey will display me a white rectangle. Of course, the images have a resolution of 1840x3264 pixels ... but is there any way to load those images correctly? If I use an image from Whatsapp or something else, it works.

Edit: Never mind. Found a solution for this second problem. Will update my module when I release it.

- /Solved -

Here is the module: http://blackbird-design.de/bbd_module.zip

And here is a test code:

Import bbd.imagepicker
Import mojo

Function Main()
	New MyApp
End

Class MyApp Extends App Implements IOnImagePickComplete
	Field imagepicker:ImagePicker
	Field myimage:Image
	
	Method OnCreate()
		imagepicker = New ImagePicker
		SetUpdateRate(60)
	End
	
	Method OnUpdate()
		UpdateAsyncEvents
		
		If TouchHit() Then imagepicker.OpenImagePickerAsync(Self)
	End
	
	Method OnRender()
		Cls()
		
		If myimage <> Null Then
			DrawImage(myimage, 0, 0)
		EndIf
		
		DrawText("Tap on the screen to open ImagePicker", 10, 10)
	End
	
	Method OnImagePickComplete:Void(result:String)
		If result <> ""
			Print result
			myimage = LoadImage(result)
			Print "Image loaded"
		EndIf
	End
	
End



nikoniko(Posted 2014) [#2]
Ironstorm wrote:
My problem is that if you browse to a directory and want to go back the imagepicker closes immediately and throw out an "RESULT_CANCELED" in "onActivityResult".
Here is a screenshot which describes my problem. If I press the button in the upper left corner or the hardware-back-button the imagepicker will be closed.


Check your public void onActivityResult code. Seems it is not correct.

Look http://sudhanshuvinodgupta.blogspot.ru/2012/07/using-intentactionpick.html for help.