import new texture
|
@ -2,6 +2,9 @@ package org.hso.texturesyncclient.controller
|
||||||
|
|
||||||
import javafx.collections.ObservableList
|
import javafx.collections.ObservableList
|
||||||
import org.hso.texturesyncclient.controller.net.Connection
|
import org.hso.texturesyncclient.controller.net.Connection
|
||||||
|
import org.hso.texturesyncclient.model.Sha256
|
||||||
|
import org.hso.texturesyncclient.model.Texture
|
||||||
|
import org.hso.texturesyncclient.model.TextureFormat
|
||||||
import org.hso.texturesyncclient.view.importView.ImportViewController
|
import org.hso.texturesyncclient.view.importView.ImportViewController
|
||||||
import org.hso.texturesyncclient.view.mainView.MainViewController
|
import org.hso.texturesyncclient.view.mainView.MainViewController
|
||||||
import org.hso.texturesyncclient.view.startupView.StartupViewController
|
import org.hso.texturesyncclient.view.startupView.StartupViewController
|
||||||
|
@ -10,6 +13,12 @@ import java.net.InetAddress
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import javax.imageio.ImageIO
|
import javax.imageio.ImageIO
|
||||||
|
import java.util.UUID
|
||||||
|
import java.nio.file.Files
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,13 +59,20 @@ 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>) {
|
||||||
|
val data = Files.readAllBytes(File(path).toPath()) // this is the image as byte array
|
||||||
|
|
||||||
val cal = Calendar.getInstance() //calendar obj with current time
|
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
|
val 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)
|
||||||
|
|
||||||
println(cal.time)
|
//Todo free image
|
||||||
println("Height: ${bimg.getHeight()} With: ${bimg.getWidth()}")
|
|
||||||
|
|
||||||
|
val newTexture = Texture(uuid, name, tags.toTypedArray(), format, resolution, cal, hash)
|
||||||
|
|
||||||
|
con.uploadTexture(newTexture, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,6 @@ import java.util.*
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DataModel
|
|
||||||
|
|
||||||
enum class TextureFormat {
|
enum class TextureFormat {
|
||||||
PNG, JPEG,
|
PNG, JPEG,
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,6 @@ class ImportViewController : Controller() {
|
||||||
private val rootc = find(RootController::class)
|
private val rootc = find(RootController::class)
|
||||||
|
|
||||||
fun btnFileChooserAction() {
|
fun btnFileChooserAction() {
|
||||||
println("btn click")
|
|
||||||
|
|
||||||
val list = listOf("*.png", "*.PNG", "*.jpg", "*.JPG", "*.jpeg", "*.JPEG")
|
val list = listOf("*.png", "*.PNG", "*.jpg", "*.JPG", "*.jpeg", "*.JPEG")
|
||||||
val arrayFilter = arrayOf(ExtensionFilter("Texturen vom Bildformat: PNG oder JPG", list))
|
val arrayFilter = arrayOf(ExtensionFilter("Texturen vom Bildformat: PNG oder JPG", list))
|
||||||
val file = chooseFile("Textur auswählen", arrayFilter, FileChooserMode.Single, owner = null)
|
val file = chooseFile("Textur auswählen", arrayFilter, FileChooserMode.Single, owner = null)
|
||||||
|
|
|
@ -10,9 +10,6 @@ import javax.swing.JColorChooser.showDialog
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MainViewController : Controller() {
|
class MainViewController : Controller() {
|
||||||
|
|
||||||
private val mv = find(MainView::class)
|
private val mv = find(MainView::class)
|
||||||
|
|
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 6.2 KiB |
After Width: | Height: | Size: 6.2 KiB |