Kebbin
02/27/2022, 11:27 AMKebbin
02/27/2022, 11:29 AMvar planPath = mutableStateOf("E:\\Users\\User\\Sample.jpg")
var planFile = File("${planPath.value}")
Image(
painter = BitmapPainter(image = loadImageBitmap(planFile.inputStream())),
contentDescription = "",
contentScale = ContentScale.Fit,
)
But when I try loading a path into planPath
from a FileDialog like this, it gives an error: (The system cannot find the path specified)
fun FrameWindowScope.setPlan(): String {
val dia = java.awt.FileDialog(window)
dia.isVisible=true
println("dia.directory: ${dia.directory} dia.file: ${dia.file}")
return if (dia.file == null) {
println("No file selected.")
""
} else {
val file = dia.directory.replace("\\","\\\\") + dia.file
println("File selected: $file")
file
}
}
The FileDialog function works, and captures the path and filename, but it must be formatting differently to the literal string?
The output of the FileDialog window appears identical to what I try manually specifying in the variable!
Thanks!Kebbin
03/02/2022, 1:04 AMZach Klippenstein (he/him) [MOD]
03/02/2022, 4:59 PMremember
.
⢠ā$somethingā
is the same as something.toString()
, and the latter form is typically preferred - if something
is a string you don't need the toString.
⢠Is loadImageBitmap
a composable or does it actually load the image? If the latter, you shouldn't call it from the composable but put it in an effect.Kebbin
03/03/2022, 2:24 AM