Lamelynx / GodotGetImagePlugin-Android

Godot plugin to select image from gallery or camera on Android device.
MIT License
71 stars 4 forks source link

Multi Image gallery selection does not work #5

Closed giamo152 closed 3 years ago

giamo152 commented 3 years ago

Hi, the multi image selection on the example provided does not work. It behaves just like the single selection. Anything I missing?

Lamelynx commented 3 years ago

The example project is loading all images into the same texture and overwrites the previous image. Therfore you should only see the last selected image (probably?). If you connect with logcat you should see the line "We are now loading texture... 1", "We are now loading texture... 2", and so on . See the code below.

I have not checked this in the latest release tough.

func _on_image_request_completed(dict):
    """ Returns Dictionary of PoolByteArray """
    var count = 0
    for img_buffer in dict.values():
        count += 1
        var image = Image.new()

        # Use load format depending what you have set in plugin setOption()
        var error = image.load_jpg_from_buffer(img_buffer)
        #var error = image.load_png_from_buffer(img_buffer)

        if error != OK:
            print("Error loading png/jpg buffer, ", error)
        else:
            print("We are now loading texture... ", count)  ### <------ This outputs to logcat
            yield(get_tree(), "idle_frame")
            var texture = ImageTexture.new()
            texture.create_from_image(image, 0)
            get_node("VBoxContainer/Image").texture = texture