@@ -6,33 +6,25 @@ import com.littlekt.audio.AudioStream
66import com.littlekt.audio.OpenALAudioClip
77import com.littlekt.audio.OpenALAudioStream
88import com.littlekt.file.ByteBufferImpl
9- import com.littlekt.file.ImageUtils
109import com.littlekt.file.JvmByteSequenceStream
1110import com.littlekt.graphics.Pixmap
1211import com.littlekt.graphics.PixmapTexture
1312import com.littlekt.graphics.Texture
1413import com.littlekt.graphics.webgpu.TextureFormat
1514import com.littlekt.log.Logger
16- import fr.delthas.javamp3.Sound
15+ import fr.delthas.javamp3.Soundgit
1716import java.io.ByteArrayInputStream
1817import java.nio.ByteBuffer
1918import java.nio.IntBuffer
20- import javax.imageio.ImageIO
2119import javax.sound.sampled.AudioSystem
2220import org.lwjgl.stb.STBImage.*
2321import org.lwjgl.system.MemoryStack
2422import org.lwjgl.system.MemoryUtil
2523
2624private val logger = Logger (" VfsLoaders" )
27- private val imageIoLock = Any ()
2825
2926/* * Reads Base64 encoded ByteArray for embedded images. */
30- internal actual suspend fun ByteArray.readPixmap (): Pixmap {
31- // ImageIO.read is not thread safe!
32- val img = synchronized(imageIoLock) { ImageIO .read(ByteArrayInputStream (this )) }
33- val result = ImageUtils .bufferedImageToBuffer(img, " RGBA" , img.width, img.height)
34- return Pixmap (img.width, img.height, result.buffer)
35- }
27+ internal actual suspend fun ByteArray.readPixmap (): Pixmap = readPixmap(this )
3628
3729/* *
3830 * Loads an image from the path as a [Pixmap].
@@ -128,7 +120,7 @@ private suspend fun VfsFile.createAudioStreamMp3(): OpenALAudioStream {
128120 read,
129121 reset,
130122 channels,
131- decoder.samplingFrequency
123+ decoder.samplingFrequency,
132124 )
133125}
134126
@@ -153,6 +145,6 @@ private suspend fun VfsFile.createAudioStreamWav(): OpenALAudioStream {
153145 read,
154146 reset,
155147 clip.format.channels,
156- clip.format.sampleRate.toInt()
148+ clip.format.sampleRate.toInt(),
157149 )
158150}
0 commit comments