@@ -125,6 +125,9 @@ class MainActivity : ComponentActivity() {
125125 var imagesArray = remember {
126126 mutableStateListOf<Bitmap >()
127127 }
128+ var drawablesArray = remember {
129+ mutableStateListOf<Drawable >()
130+ }
128131 LaunchedEffect (key1 = Unit , block = {
129132 lifecycleScope.launch(Dispatchers .IO ) {
130133 val buffer5 =
@@ -183,59 +186,66 @@ class MainActivity : ComponentActivity() {
183186// lifecycleScope.launch {
184187// drawables.add(BitmapDrawable(resources, bitmap))
185188// }
186- val space = bitmap.copy(Bitmap .Config .ARGB_8888 , true )
187- val encoded =
188- JxlCoder .encode(
189- space,
190- channelsConfiguration = JxlChannelsConfiguration .RGB ,
191- effort = JxlEffort .LIGHTNING ,
192- compressionOption = JxlCompressionOption .LOSSLESS ,
193- quality = 100 ,
194- )
195- val decoded = JxlCoder .decodeSampled(
196- encoded,
197- preferredColorConfig = PreferredColorConfig .RGBA_8888 , width = 1305 ,
198- height = 1295
199- )
200- lifecycleScope.launch {
201- imagesArray.add(decoded)
202- }
189+ // val space = bitmap.copy(Bitmap.Config.ARGB_8888, true)
190+ // val encoded =
191+ // JxlCoder.encode(
192+ // space,
193+ // channelsConfiguration = JxlChannelsConfiguration.RGB,
194+ // effort = JxlEffort.LIGHTNING,
195+ // compressionOption = JxlCompressionOption.LOSSLESS,
196+ // quality = 100,
197+ // )
198+ // val decoded = JxlCoder.decodeSampled(
199+ // encoded,
200+ // preferredColorConfig = PreferredColorConfig.HARDWARE , width = 1305,
201+ // height = 1295
202+ // )
203+ // lifecycleScope.launch {
204+ // imagesArray.add(decoded)
205+ // }
203206
204- // var assets =
205- // ([email protected] ("") ?: return@launch).toList()206- // // assets = assets.filter { it.contains("20181110_213419__MMC1561-HDR.jxl") }
207- // for (asset in assets) {
208- // try {
209- // val buffer4 =
210- // [email protected] (asset).source().buffer()211- // .readByteArray()
212- //
213- // val largeImageSize = JxlCoder.getSize(buffer4)
214- // if (largeImageSize != null) {
215- // val time = measureTimeMillis {
207+ var assets =
208+ (this @MainActivity.assets.list(" " ) ? : return @launch).toList()
209+ assets = assets.filter { it.contains(" 20181110_213419__MMC1561-HDR.jxl" ) }
210+ for (asset in assets) {
211+ try {
212+ val buffer4 =
213+ this @MainActivity.assets.open(asset).source().buffer()
214+ .readByteArray()
215+
216+ val largeImageSize = JxlCoder .getSize(buffer4)
217+ if (largeImageSize != null ) {
218+ val time = measureTimeMillis {
216219// val srcImage = JxlCoder.decodeSampled(
217220// buffer4,
218221// largeImageSize.width / 2,
219222// largeImageSize.height / 2,
220- // preferredColorConfig = PreferredColorConfig.RGBA_8888 ,
223+ // preferredColorConfig = PreferredColorConfig.HARDWARE ,
221224// com.awxkee.jxlcoder.ScaleMode.FIT,
222225// toneMapper = JxlToneMapper.REC2408,
223226// )
224- // // val srcImage = JxlCoder.decode(buffer4,
225- // // preferredColorConfig = PreferredColorConfig.RGB_565,
226- // // toneMapper = JxlToneMapper.REC2408)
227+ val animatedImage = JxlAnimatedImage (
228+ buffer4,
229+ preferredColorConfig = PreferredColorConfig .HARDWARE ,
230+ scaleMode = ScaleMode .FIT ,
231+ toneMapper = JxlToneMapper .REC2408 ,
232+ )
233+ drawablesArray.add(animatedImage.animatedDrawable)
234+ // val srcImage = JxlCoder.decode(buffer4,
235+ // preferredColorConfig = PreferredColorConfig.RGB_565,
236+ // toneMapper = JxlToneMapper.REC2408)
227237// lifecycleScope.launch {
228238// imagesArray.add(srcImage)
229239// }
230- // }
231- // Log.d("JXLCoder", "Decoding done in ${time}ms")
232- // }
233- // } catch (e: Exception) {
234- // if (e !is FileNotFoundException) {
235- // throw e
236- // }
237- // }
238- // }
240+ }
241+ Log .d(" JXLCoder" , " Decoding done in ${time} ms" )
242+ }
243+ } catch (e: Exception ) {
244+ if (e !is FileNotFoundException ) {
245+ throw e
246+ }
247+ }
248+ }
239249 }
240250 })
241251 // A surface container using the 'background' color from the theme
@@ -276,6 +286,17 @@ class MainActivity : ComponentActivity() {
276286 contentDescription = " ok"
277287 )
278288 }
289+
290+ // items(drawablesArray.count(), key = {
291+ // return@items UUID.randomUUID().toString()
292+ // }) {
293+ // Image(
294+ // rememberDrawablePainter(drawable = drawablesArray[it]),
295+ // modifier = Modifier.fillMaxWidth(),
296+ // contentScale = ContentScale.FillWidth,
297+ // contentDescription = "ok"
298+ // )
299+ // }
279300 }
280301 }
281302 }
0 commit comments