removed unused

This commit is contained in:
Avently
2024-04-30 18:07:04 +07:00
parent 1d5f0bcae2
commit fa05c351f4
3 changed files with 1 additions and 62 deletions
@@ -102,7 +102,6 @@ kotlin {
implementation("uk.co.caprica:vlcj:4.8.2")
implementation("com.github.NanoHttpd.nanohttpd:nanohttpd:efb2ebf85a")
implementation("com.github.NanoHttpd.nanohttpd:nanohttpd-websocket:efb2ebf85a")
implementation("org.apache.xmlgraphics:batik-transcoder:1.16")
}
}
val desktopTest by getting
@@ -1,59 +0,0 @@
/*
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/
package chat.simplex.common.other.mokoresources
import chat.simplex.res.MR.assets.resourcesClassLoader
import dev.icerock.moko.resources.ImageResource
import org.apache.batik.transcoder.*
import org.apache.batik.transcoder.image.PNGTranscoder
import java.awt.image.BufferedImage
import java.io.File
import java.io.FileNotFoundException
import java.io.InputStream
import javax.imageio.ImageIO
private var cache: Pair<String, BufferedImage>? = null
// Get rid of this file when we update to moko-resources >= 0.24.0 and use `image` instead of `customImage()`
// See https://github.com/icerockdev/moko-resources/commit/93900ca2690d2c70cf4db24902a4b89f30877176
fun ImageResource.customImage(): BufferedImage {
if (cache?.first == filePath) return cache!!.second
val stream = resourcesClassLoader.getResourceAsStream(filePath)
?: throw FileNotFoundException("Couldn't open resource as stream at: $filePath")
val res = stream.use {
if (filePath.endsWith(".svg", ignoreCase = true)) {
readSvg(it)
} else {
ImageIO.read(it)
}
}
cache = filePath to res
return res
}
private fun readSvg(
inputStream: InputStream
): BufferedImage {
// Create a PNG transcoder.
val t: Transcoder = PNGTranscoder()
// Create the transcoder input.
val input = TranscoderInput(inputStream)
// Create the transcoder output.
val tempFile: File = File.createTempFile("moko-resources", ".png")
try {
tempFile.outputStream().use {
val output = TranscoderOutput(it)
t.transcode(input, output)
}
return tempFile.inputStream().use {
ImageIO.read(it)
}
} finally {
tempFile.delete()
}
}
@@ -7,7 +7,6 @@ import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.*
import chat.simplex.common.other.mokoresources.customImage
import chat.simplex.common.simplexWindowState
import com.russhwolf.settings.*
import dev.icerock.moko.resources.ImageResource
@@ -64,4 +63,4 @@ actual fun isRtl(text: CharSequence): Boolean {
}
actual fun ImageResource.toComposeImageBitmap(): ImageBitmap? =
customImage().toComposeImageBitmap()
image.toComposeImageBitmap()