MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / fromFile

Method fromFile

src/main/java/field/graphics/TextureArray.kt:108–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106
107
108 @JvmStatic
109 // because of the way that this rewrites the unit of a, potentially already loaded, texture list this isn't very useful outside of the context of Trace
110 fun fromFile(unit: Int, fn: String): TextureArray? {
111
112 val uu = dirCache.computeIfAbsent(fn) {
113 val jj = mutableListOf(File(fn))
114
115 jj.sort()
116
117 val dim = SlowJPEG().dimensions(jj[0].absolutePath)
118
119 val dat = ByteBuffer.allocateDirect(dim[0] * dim[1] * 3 * jj.size)
120
121 jj.forEachIndexed { i, n ->
122 dat.position(i * dim[0] * dim[1] * 3)
123 dat.limit((i + 1) * dim[0] * dim[1] * 3)
124 SlowJPEG().decompressRaw(n.absolutePath, dat, dim[0], dim[1])
125 dat.clear()
126
127 }
128 dat.clear()
129
130 TextureArray(unit, dim[0], dim[1], jj.size, dat)
131 }
132 uu?.unit = unit
133 return uu
134 }
135
136 }
137}

Callers

nothing calls this directly

Calls 9

FileFunction · 0.85
SlowJPEGClass · 0.85
TextureArrayClass · 0.85
computeIfAbsentMethod · 0.80
decompressRawMethod · 0.80
dimensionsMethod · 0.65
positionMethod · 0.65
limitMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected