I want to rotate and zoom an image with sliders and save the edited image to storage in Android how can I do it?
Please let me know if this solution is not suitable.
var sliderRotation by remember { mutableFloatStateOf(1f) }
var sliderZoom by remember { mutableFloatStateOf(1f) }
val imageLoader = ImageLoader.Builder(context)
.build()
Scaffold(
modifier = Modifier.fillMaxSize(),
topBar = {
MainToolbar(title = R.string.edit_image)
}
) { paddingValue ->
Column(
modifier = Modifier
.fillMaxSize()
.padding(paddingValue),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
Box(
modifier = Modifier
.fillMaxWidth()
.weight(1f)
) {
AsyncImage(
modifier = Modifier
.fillMaxSize()
.scale(sliderZoom)
.rotate(sliderRotation),
contentDescription = "Zoomable image",
model = ImageRequest.Builder(context)
.data(uiState.editImageUri.toString())
.build(),
imageLoader = imageLoader,
)
}
Column(
modifier = Modifier
.fillMaxWidth()
.weight(1f),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
SliderRow(
sliderValue = sliderRotation,
onValueChange = {
sliderRotation = it },
title = stringResource(R.string.size)
) {
Icon(
painter = painterResource(id = R.drawable.repeat),
contentDescription = "repeat icon",
tint = Color.Unspecified
)
}
SliderRow(
sliderValue = sliderZoom,
onValueChange = { sliderZoom = it },
title = stringResource(R.string.zoom)
) {
Icon(
painter = painterResource(id = R.drawable.repeat),
contentDescription = "repeat icon",
tint = Color.Unspecified
)
}
Button(onClick = { }) {
}
}
}
}