diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt b/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt index f03247b..d163176 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt @@ -2,6 +2,9 @@ package org.hso.texturesyncclient.controller import javafx.collections.ObservableList 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.mainView.MainViewController import org.hso.texturesyncclient.view.startupView.StartupViewController @@ -10,6 +13,12 @@ import java.net.InetAddress import java.util.Calendar import java.io.File 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 */ fun importTexture(path: String, name: String, tags: ObservableList) { + 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 resolution = Pair(bimg.height, bimg.width) + val cal = Calendar.getInstance() //calendar obj with current time + val hash = Sha256(data) - println(cal.time) - println("Height: ${bimg.getHeight()} With: ${bimg.getWidth()}") + //Todo free image + val newTexture = Texture(uuid, name, tags.toTypedArray(), format, resolution, cal, hash) + + con.uploadTexture(newTexture, data) } diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/model/DataModel.kt b/client/src/main/kotlin/org/hso/texturesyncclient/model/DataModel.kt index e75febd..0e3b270 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/model/DataModel.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/model/DataModel.kt @@ -5,9 +5,6 @@ import java.util.* import java.security.MessageDigest - -class DataModel - enum class TextureFormat { PNG, JPEG, } diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportViewController.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportViewController.kt index 41e6ad7..6f8d26b 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportViewController.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportViewController.kt @@ -12,8 +12,6 @@ class ImportViewController : Controller() { private val rootc = find(RootController::class) fun btnFileChooserAction() { - println("btn click") - val list = listOf("*.png", "*.PNG", "*.jpg", "*.JPG", "*.jpeg", "*.JPEG") val arrayFilter = arrayOf(ExtensionFilter("Texturen vom Bildformat: PNG oder JPG", list)) val file = chooseFile("Textur auswählen", arrayFilter, FileChooserMode.Single, owner = null) diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt index 7eb93c5..7e6ae7a 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt @@ -10,9 +10,6 @@ import javax.swing.JColorChooser.showDialog import java.io.File - - - class MainViewController : Controller() { private val mv = find(MainView::class) diff --git a/client/src/main/resources/textures/sample_texture_3.PNG b/client/src/main/resources/textures/sample_texture_3.PNG new file mode 100644 index 0000000..714b9b8 Binary files /dev/null and b/client/src/main/resources/textures/sample_texture_3.PNG differ diff --git a/client/src/main/resources/textures/sample_texture_4.png b/client/src/main/resources/textures/sample_texture_4.png new file mode 100644 index 0000000..714b9b8 Binary files /dev/null and b/client/src/main/resources/textures/sample_texture_4.png differ diff --git a/client/src/main/resources/textures/sample_texture_5.JPG b/client/src/main/resources/textures/sample_texture_5.JPG new file mode 100644 index 0000000..5f98215 Binary files /dev/null and b/client/src/main/resources/textures/sample_texture_5.JPG differ diff --git a/client/src/main/resources/textures/sample_texture_6.JPEG b/client/src/main/resources/textures/sample_texture_6.JPEG new file mode 100644 index 0000000..5f98215 Binary files /dev/null and b/client/src/main/resources/textures/sample_texture_6.JPEG differ