mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -04:00
fix fallback texture reading when alpha is in raster
This commit is contained in:
parent
deeb997541
commit
06a98fedfe
@ -57,17 +57,25 @@ object TextureUtil {
|
|||||||
val byteOutput = ByteArrayOutputStream()
|
val byteOutput = ByteArrayOutputStream()
|
||||||
val dataOutput = DataOutputStream(byteOutput)
|
val dataOutput = DataOutputStream(byteOutput)
|
||||||
|
|
||||||
val samples = if (image.raster.numBands == 3) intArrayOf(0, 1, 2) else intArrayOf(0, 0, 0)
|
val samples = when (image.raster.numBands) {
|
||||||
|
4 -> intArrayOf(0, 1, 2, 3)
|
||||||
|
3 -> intArrayOf(0, 1, 2)
|
||||||
|
else -> intArrayOf(0, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
for (y in 0 until image.height) {
|
for (y in 0 until image.height) {
|
||||||
for (x in 0 until image.width) {
|
for (x in 0 until image.width) {
|
||||||
dataOutput.writeByte(image.raster.getSample(x, y, samples[0]))
|
dataOutput.writeByte(image.raster.getSample(x, y, samples[0]))
|
||||||
dataOutput.writeByte(image.raster.getSample(x, y, samples[1]))
|
dataOutput.writeByte(image.raster.getSample(x, y, samples[1]))
|
||||||
dataOutput.writeByte(image.raster.getSample(x, y, samples[2]))
|
dataOutput.writeByte(image.raster.getSample(x, y, samples[2]))
|
||||||
|
if (samples.size > 3) {
|
||||||
|
dataOutput.writeByte(image.raster.getSample(x, y, samples[3]))
|
||||||
|
} else {
|
||||||
val alpha = image.alphaRaster?.getSample(x, y, 0) ?: 0xFF
|
val alpha = image.alphaRaster?.getSample(x, y, 0) ?: 0xFF
|
||||||
dataOutput.writeByte(alpha)
|
dataOutput.writeByte(alpha)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val buffer = MemoryUtil.memAlloc(byteOutput.size())
|
val buffer = MemoryUtil.memAlloc(byteOutput.size())
|
||||||
buffer.put(byteOutput.toByteArray())
|
buffer.put(byteOutput.toByteArray())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user