Capturable: Can't get the Bitmap when Capturable includes Network image
Hello!! When I press the button where I have the controller.capture function, I get the same error all the time, at first I thought I had something wrong configured, I cloned the repository to see the example, and I had it similar, but the example does not give me the same error as me
Error obtained
java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps
Capturable
Capturable(
modifier = Modifier.constrainAs(ivLetterImage) {
linkTo(parent.start, parent.end)
linkTo(parent.top, tvAddressee.top)
width = Dimension.fillToConstraints
},
controller = controller,
onCaptured = { bitmap, error ->
//ticketBitmap = bitmap
error
context.share(
nameOfImage = letters,
message = "",
bitmap = bitmap?.asAndroidBitmap().orEmpty()
)
}
) {
LetterImage(
addressee = addressee.value.text,
message = message.value.text,
sender = sender.value.text,
letterImage = letterImage
)
}
LetterImage Composable
@ExperimentalFoundationApi
@Composable
fun LetterImage(
modifier: Modifier = Modifier,
addressee: String,
message: String,
sender: String,
letterImage: String
) {
ConstraintLayout(
modifier = modifier
) {
val (
ivLetter,
tvAddressee,
tvMessage,
tvSender
) = createRefs()
NetworkImage(
modifier = Modifier
.wrapContentHeight()
.fillMaxWidth()
.constrainAs(ivLetter) {
linkTo(parent.start, parent.end)
linkTo(parent.top, parent.bottom)
},
contentScale = ContentScale.Crop,
url = letterImage,
builder = {
crossfade(true)
}
)
Text(
text = addressee,
maxLines = 1,
color = lightGreyPastel,
fontWeight = FontWeight.Bold,
style = TypographyNook.h6,
modifier = Modifier
.padding(top = 30.dp, start = 40.dp)
.constrainAs(tvAddressee) {
start.linkTo(parent.start)
top.linkTo(ivLetter.top)
}
)
Text(
text = message,
maxLines = 7,
color = lightGreyPastel,
fontWeight = FontWeight.Bold,
style = TypographyNook.h6,
modifier = Modifier
.padding(top = 20.dp, start = 60.dp, end = 60.dp)
.constrainAs(tvMessage) {
linkTo(parent.start, parent.end)
top.linkTo(tvAddressee.bottom)
bottom.linkTo(tvSender.top)
}
)
Text(
text = sender, //16,
maxLines = 1,
color = lightGreyPastel,
fontWeight = FontWeight.Bold,
style = TypographyNook.h6,
modifier = Modifier
.padding(top = 20.dp, bottom = 30.dp, end = 40.dp)
.constrainAs(tvSender) {
end.linkTo(parent.end)
linkTo(tvMessage.bottom, parent.bottom)
}
)
}
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (7 by maintainers)
Commits related to this issue
- [#7] Fix capturing bitmap for device with API 26 and above using PixelCopy API — committed to PatilShreyas/Capturable by PatilShreyas 2 years ago
- [#7] Update Capturable doc with usage — committed to PatilShreyas/Capturable by PatilShreyas 2 years ago
- Merge pull request #9 from PatilShreyas/fix/7-hw-bmp Fix #7: IllegalArgumentException: Software rendering doesn't support hardware bitmaps — committed to PatilShreyas/Capturable by PatilShreyas 2 years ago
@Jeluchu This has been released in
v1.0.2
As mentioned here: https://github.com/PatilShreyas/Capturable/pull/9#issue-1111822044
Thanks, @Jeluchu for this helpful finding and for making it better 😀. This will be released in
v1.0.2
Thanks @Jeluchu for the detailed info, will look into it.
The log which you shared here is about
NullPointerException
occurring in your code which is related touriString
variable.For saving bitmap, you can refer to this code
Closing this issue since this doesn’t looks like associated with the library.