Thread
#compose
    e

    Evgeniy Shmoilov

    1 year ago
    Hi! Is there a way to get pixel color on
    Canvas
    by coordinates?
    Adam Powell

    Adam Powell

    1 year ago
    What is your use case? Generally it is quite slow to read pixels back from GPU memory. If you are working from source data like an image or other data derived from app state, it's better to get what you need from there instead of from final pixels.
    r

    romainguy

    1 year ago
    Getting a pixel color would mean interrupting command recording, flushing the command buffer to the render thread then GPU, then wait for frame completion for readback, all the while blocking the main thread
    That or you'd get the previous frame's color (which may not exist)
    A cheaper way is to draw what you want to draw in a Bitmap (it can even be 1x1) and read back from that
    e

    Evgeniy Shmoilov

    1 year ago
    I am implementing a recursive flood fill algorithm as part of a lab
    r

    romainguy

    1 year ago
    You should do this on a
    Canvas
    that wraps a
    Bitmap
    then
    Or better yet, directly in an array of integers that you then convert to a
    Bitmap
    Kyant

    Kyant

    1 year ago
    Is there a way to convert Composables to Bitmap?
    r

    romainguy

    1 year ago
    You can use a ComposeView to host your composables and draw that view into a Bitmap
    Kyant

    Kyant

    1 year ago
    Oh, I crashed with "width and height must be > 0"
    r

    romainguy

    1 year ago
    Well how big is your Bitmap? 🙂
    Kyant

    Kyant

    1 year ago
    The problem has been resolved. 😀
    I see there is a Modifier.blur() proposal in the issue tracker, when it will be implemented?
    r

    romainguy

    1 year ago
    Any updates will be posted on the bug