Merge commit 'efc2845' into resize
This commit is contained in:
commit
9a3524143a
|
@ -48,11 +48,11 @@ class RootController : Controller() {
|
||||||
* @param tags all tags for the file
|
* @param tags all tags for the file
|
||||||
*/
|
*/
|
||||||
fun importTexture(path: String, name: String, tags: ObservableList<String>) {
|
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 uuid = UUID.randomUUID()
|
||||||
val format = if (File(path).extension.toLowerCase() == "png") TextureFormat.PNG else TextureFormat.JPEG
|
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 resolution = Pair(bimg.height, bimg.width)
|
||||||
val cal = Calendar.getInstance() //calendar obj with current time
|
val cal = Calendar.getInstance() //calendar obj with current time
|
||||||
val hash = Sha256(data)
|
val hash = Sha256(data)
|
||||||
|
@ -72,7 +72,6 @@ class RootController : Controller() {
|
||||||
"-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;"
|
"-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)
|
val newTexture = Texture(uuid, name, tags.toTypedArray(), format, resolution, cal, hash)
|
||||||
|
|
||||||
|
@ -84,7 +83,9 @@ class RootController : Controller() {
|
||||||
alertImportHash.showAndWait()
|
alertImportHash.showAndWait()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
alertImport.showAndWait()
|
alertImport.showAndWait()
|
||||||
|
println(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue