korge icon indicating copy to clipboard operation
korge copied to clipboard

Exception when trying to readBitmap() JPEG

Open lemkoleg opened this issue 5 months ago • 5 comments

 val l = localVfs(fullName).readAll()
 val file = l.openAsync().asVfsFile()
 Log.WriteLog("AAA", "Im here 1")
 val image = file.readBitmap()
 Log.WriteLog("AAA", "Im here 2")
 val image32 = image.toBMP32()
 Log.WriteLog("AAA", "Im here 3")
Im here 1
Exception java.lang.UnsupportedOperationException: No suitable image format : MAGIC: Ï ß(ffd8ffe1) ( Ï ß)
    	at korlibs.image.format.ImageFormats.readImageContainer(ImageFormats.kt:148)
    	at korlibs.image.format.ImageFormat.readImage(ImageFormat.kt:39)
    	at korlibs.image.format.ImageFormat.read(ImageFormat.kt:68)
    	at korlibs.image.format.ImageFormat.decode(ImageFormat.kt:83)
    	at korlibs.image.format.KorioExtKt._readBitmap(KorioExt.kt:112)
    	at korlibs.image.format.KorioExtKt._readBitmap$default(KorioExt.kt:94)
    	at korlibs.image.format.KorioExtKt.readBitmap(KorioExt.kt:24)

lemkoleg avatar Aug 20 '25 14:08 lemkoleg

What exactly are you trying to do? Just load an image to Display? Also please share your whole code

FSaurenbach avatar Aug 25 '25 15:08 FSaurenbach

var whiteRook = resourcesVfs["w_rook.png"].readBitmap() If you Just want to load a simple Image just do that

FSaurenbach avatar Aug 25 '25 15:08 FSaurenbach

I want to read the image as Bitmap32 so I can do some cropping manipulations on it like this Bitmap32.mipmap()

lemkoleg avatar Aug 26 '25 07:08 lemkoleg

Well I guess you are just reading the bitmap wrong, try swapping out localVFS for resourcesVfs as in the docs. https://docs.korge.org/resources/ ->reading Bitmaps https://docs.korge.org/imaging/bitmap/ -> Cropping help

FSaurenbach avatar Aug 26 '25 07:08 FSaurenbach

I'm trying to optimize image from an arbitrary file or from a byte array, in JPEG-format. Not a resource file. This worked fine before

lemkoleg avatar Aug 26 '25 18:08 lemkoleg