October 22, 2024
Chicago 12, Melborne City, USA
Android

Bitmap in Kotlin with Jetpack, won't draw the correct size


This has been driving me crazy all day. I have been trying to draw a full screen bitmap as the background for my custom view. The bitmap resolution is 2312×1080 the code right before I draw it shows both my canvas that I’m in and my bitmap are also 2312×1080 (these two log functions). But it keeps drawing the image so that the bottom and right are a little bit cut off. I made a checkerboard test image to check. For the life of me I can’t figure out what’s going wrong. Anyone have any ideas?

    Log.d("GridView", "Loaded bitmap dimensions - width: ${bitmap?.width}, height: ${bitmap?.height}")
    Log.d("GridView", "Canvas size - width: ${size.width}, height: ${size.height}")

    //draw the background image
    bitmap?.let { image ->
        drawImage(
            image = image,
            topLeft = Offset.Zero,

        )
    }



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video