fixed error handling at import

This commit is contained in:
Hendrik Schutter 2019-06-09 13:29:07 +02:00
parent 15cbbb1bac
commit efc28455c1
1 changed files with 4 additions and 3 deletions

View File

@ -49,11 +49,11 @@ class RootController : Controller() {
* @param tags all tags for the file
*/
fun importTexture(path: String, name: String, tags: ObservableList<String>) {
var data = Files.readAllBytes(File(path).toPath()) // this is the image as byte array
val data = Files.readAllBytes(File(path).toPath()) // this is the image as byte array
val uuid = UUID.randomUUID()
val format = if (File(path).extension.toLowerCase() == "png") TextureFormat.PNG else TextureFormat.JPEG
val bimg = ImageIO.read(File(path)) //image for obtaining resolution
var bimg = ImageIO.read(File(path)) //image for obtaining resolution
val resolution = Pair(bimg.height, bimg.width)
val cal = Calendar.getInstance() //calendar obj with current time
val hash = Sha256(data)
@ -73,7 +73,6 @@ class RootController : Controller() {
"-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;"
)
data = null //Free image
val newTexture = Texture(uuid, name, tags.toTypedArray(), format, resolution, cal, hash)
@ -85,7 +84,9 @@ class RootController : Controller() {
alertImportHash.showAndWait()
} catch (e: Exception) {
alertImport.showAndWait()
println(e)
}
}
/**