0

I'm trying write compose to bitmap. https://developer.android.com/develop/ui/compose/graphics/draw/modifiers#composable-to-bitmap

Text("Hello $name!",
     modifier = Modifier
         .drawWithContent {
             graphicsLayer.record {
                 [email protected]()
             }
             drawLayer(graphicsLayer)
         },
)
IconButton({
    scope.launch(Dispatchers.IO) {
          mBitmap = graphicsLayer.toImageBitmap()
          showDialog = true
    }
 } ...

On Samsung SM-A720F (Android 8) I got:

Wrong bitmap

Like horizontal synchronization failure.

On other smartphones and emulator I got the corrent bitmap:

Right bitmap

How to fix this bug on Samsung SM-A720F?

3
  • That probably will be tricky to track down. I could not reproduce the issue on my phone. I would suggest that you investigate this issue further. Does it also happen when you display your image somewhere else instead of in the dialog? Does it work correctly when using the old APIs to capture a Composable? Check out this library: github.com/PatilShreyas/Capturable/tree/… Until version 2.1, it used the old APIs. Starting from version 3.0.0, it uses the new APIs. Try both versions and see if the older version fixes the problem on your Samsung. Commented Nov 27, 2024 at 7:45
  • I made something like the Toy Paint app. I've saved pictures in jpeg files and got that glitch on Samsung SM-A720F . github.com/s3va/My_Paint . Dialog is only for MRE. So it happen not only in the Dialog. I haven't tried the old APIs to capture a Composable yet. Commented Nov 27, 2024 at 12:25
  • This method with Picture() works fine on Samsung SM-A720F. stackoverflow.com/a/77597340/11798617 Commented Nov 27, 2024 at 20:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.