desktop: saving qr code as an image (#3572)
This commit is contained in:
parent
26a189917b
commit
5e042d222e
@ -67,7 +67,7 @@ fun QRCode(
|
|||||||
scope.launch {
|
scope.launch {
|
||||||
val image = qrCodeBitmap(connReq, 1024).replaceColor(Color.Black.toArgb(), tintColor.toArgb())
|
val image = qrCodeBitmap(connReq, 1024).replaceColor(Color.Black.toArgb(), tintColor.toArgb())
|
||||||
.let { if (withLogo) it.addLogo() else it }
|
.let { if (withLogo) it.addLogo() else it }
|
||||||
val file = saveTempImageUncompressed(image, false)
|
val file = saveTempImageUncompressed(image, true)
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
shareFile("", CryptoFile.plain(file.absolutePath))
|
shareFile("", CryptoFile.plain(file.absolutePath))
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@ import androidx.compose.ui.text.*
|
|||||||
import androidx.compose.ui.text.font.FontStyle
|
import androidx.compose.ui.text.font.FontStyle
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.Density
|
import androidx.compose.ui.unit.Density
|
||||||
import chat.simplex.common.model.*
|
import chat.simplex.common.model.CIFile
|
||||||
|
import chat.simplex.common.model.readCryptoFile
|
||||||
import chat.simplex.common.platform.*
|
import chat.simplex.common.platform.*
|
||||||
import chat.simplex.common.simplexWindowState
|
import chat.simplex.common.simplexWindowState
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.*
|
||||||
import java.io.File
|
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import javax.imageio.ImageIO
|
import javax.imageio.ImageIO
|
||||||
import kotlin.io.encoding.Base64
|
import kotlin.io.encoding.Base64
|
||||||
@ -148,9 +148,8 @@ actual suspend fun saveTempImageUncompressed(image: ImageBitmap, asPng: Boolean)
|
|||||||
return if (file != null) {
|
return if (file != null) {
|
||||||
try {
|
try {
|
||||||
val ext = if (asPng) "png" else "jpg"
|
val ext = if (asPng) "png" else "jpg"
|
||||||
val newFile = File(file.absolutePath + File.separator + generateNewFileName("IMG", ext, File(getAppFilePath(""))))
|
val newFile = File(file.absolutePath + File.separator + generateNewFileName("IMG", ext, File(file.absolutePath)))
|
||||||
// LALAL FILE IS EMPTY
|
ImageIO.write(image.toAwtImage(), ext, newFile.outputStream())
|
||||||
ImageIO.write(image.toAwtImage(), ext.uppercase(), newFile.outputStream())
|
|
||||||
newFile
|
newFile
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "Util.kt saveTempImageUncompressed error: ${e.message}")
|
Log.e(TAG, "Util.kt saveTempImageUncompressed error: ${e.message}")
|
||||||
|
Loading…
Reference in New Issue
Block a user