diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/image/Image.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/image/Image.kt index 6f7cd3ae..4d50d168 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/image/Image.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/image/Image.kt @@ -315,12 +315,16 @@ class Image private constructor( val getHeight = intArrayOf(0) val components = intArrayOf(0) + val idata = it.readDirect() + val data = STBImage.stbi_load_from_memory( - it.readDirect(), + idata, getWidth, getHeight, components, 0 ) ?: throw IllegalArgumentException("File $it is not an image or it is corrupted") + synchronized(idata) {} // memory barrier + val address = MemoryUtil.memAddress(data) Starbound.CLEANER.register(data) { STBImage.nstbi_image_free(address) }