Initial commit: InTono — app KMP per l'apprendimento musicale
App Kotlin Multiplatform (Android/iOS/Desktop) con Compose Multiplatform: controllo intonazione (YIN), pratica guidata, metronomo, ear training, sfide, scansione spartiti via AI, spartiti bundled e pentagramma con glifi tipografici, travature, battute e spaziatura proporzionale. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
commit
21ad969b10
245 files changed
+28963
No files matched your search
@@ -0,0 +1,26 @@
|
||||
package com.notemusicali.scan
|
||||
|
||||
import java.awt.image.BufferedImage
|
||||
import java.io.ByteArrayOutputStream
|
||||
import javax.imageio.ImageIO
|
||||
|
||||
actual typealias PlatformImage = BufferedImage
|
||||
|
||||
actual fun PlatformImage.toBase64Jpeg(maxDim: Int, quality: Int): String {
|
||||
val scaled = if (width > maxDim || height > maxDim) {
|
||||
val scale = maxDim.toDouble() / maxOf(width, height)
|
||||
val newW = (width * scale).toInt()
|
||||
val newH = (height * scale).toInt()
|
||||
val img = BufferedImage(newW, newH, BufferedImage.TYPE_INT_RGB)
|
||||
val g = img.createGraphics()
|
||||
g.drawImage(this, 0, 0, newW, newH, null)
|
||||
g.dispose()
|
||||
img
|
||||
} else {
|
||||
this
|
||||
}
|
||||
|
||||
val stream = ByteArrayOutputStream()
|
||||
ImageIO.write(scaled, "JPEG", stream)
|
||||
return java.util.Base64.getEncoder().encodeToString(stream.toByteArray())
|
||||
}
|
||||
Reference in new issue
Block a user