My observations on the state of affairs. Some tim...
# compose
s
My observations on the state of affairs. Some time ago, quite often(480+ messages) users had the question of how to render a composable widget into a bitmap image (there are many purposes of use). But, unfortunately, there is still no single answer as to how it could be done effectively. In short, the current View system does not allow this, there's no such API. But until this moment. Android 14 DP1 is out 😲 and I think I see where this is going. New APIs have been added that perfectly match this very popular request: PixelCopy.request and PixelCopy.Request.Builder#setSourceRect(android.graphics.Rect)
PixelCopy.request
provides mechanisms that allow you to copy pixels from a
Surface/Window/View
to a
Bitmap
. It seems that this issue will finally be solved, but for users of Android 14+.
s
@ephemient Previously you could only copy from SurfaceView or Window, now this API has been extended to View and you can specify the desired area to copy. Which is very suitable for Compose, as it is one view that draws components on the canvas. Correct me if I wrong.
e
PixelCopy(window, view.getLocationInWindow())
was possible before
s
Then I don't know why it hasn't been used yet.