@@ -57,18 +57,6 @@ class MainActivity : ComponentActivity() {
5757 override fun onCreate (savedInstanceState : Bundle ? ) {
5858 super .onCreate(savedInstanceState)
5959
60- // val buffer1 = this.assets.open("hdr_cosmos.jxl").source().buffer().readByteArray()
61- // assert(JxlCoder.isJXL(buffer1))
62- // assert(JxlCoder().getSize(buffer1) != null)
63- // val iccCosmosImage = JxlCoder().decode(buffer1)
64- // val buffer2 = this.assets.open("second_jxl.jxl").source().buffer().readByteArray()
65- // assert(JxlCoder.isJXL(buffer2))
66- // assert(JxlCoder().getSize(buffer2) != null)
67- // val buffer3 = this.assets.open("alpha_jxl.jxl").source().buffer().readByteArray()
68- // assert(JxlCoder.isJXL(buffer3))
69- // assert(JxlCoder().getSize(buffer3) != null)
70-
71-
7260 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
7361// val buffer4 = this.assets.open("happy_india.jxl").source().buffer().readByteArray()
7462// assert(JxlCoder.isJXL(buffer4))
@@ -224,57 +212,21 @@ class MainActivity : ComponentActivity() {
224212 com.awxkee.jxlcoder.ScaleMode .FIT ,
225213 toneMapper = JxlToneMapper .REC2408 ,
226214 )
227- }
228- Log .d(" JXLMain" , " Decoding time ${decodingTime} ms" )
229- val time = measureTimeMillis {
215+
216+ // Resizable version
230217// val srcImage = JxlCoder.decodeSampled(
231218// buffer4,
232- // largeImageSize.width / 2,
233- // largeImageSize.height / 2,
219+ // width = largeImageSize.width / 2,
220+ // height = largeImageSize.height / 2,
234221// preferredColorConfig = PreferredColorConfig.HARDWARE,
235222// com.awxkee.jxlcoder.ScaleMode.FIT,
236223// toneMapper = JxlToneMapper.REC2408,
237224// )
238- val srcImage = JxlCoder .decode(
239- buffer4,
240- preferredColorConfig = PreferredColorConfig .HARDWARE ,
241- com.awxkee.jxlcoder.ScaleMode .FIT ,
242- toneMapper = JxlToneMapper .REC2408 ,
243- )
244- val fosRec2408 = FileOutputStream (File (cacheDir, File (asset).nameWithoutExtension + " .jpg" ))
245- fosRec2408.use {
246- srcImage.compress(Bitmap .CompressFormat .JPEG , 90 , it)
247- it.flush()
248- }
249- // val srcPerceptual = JxlCoder.decodeSampled(
250- // buffer4,
251- // largeImageSize.width / 2,
252- // largeImageSize.height / 2,
253- // preferredColorConfig = PreferredColorConfig.HARDWARE,
254- // com.awxkee.jxlcoder.ScaleMode.FIT,
255- // toneMapper = JxlToneMapper.REC2408_PERCEPTUAL,
256- // )
257- val srcPerceptual = JxlCoder .decode(
258- buffer4,
259- preferredColorConfig = PreferredColorConfig .HARDWARE ,
260- com.awxkee.jxlcoder.ScaleMode .FIT ,
261- toneMapper = JxlToneMapper .REC2408_PERCEPTUAL ,
262- )
263- val fosRec2408Perc = FileOutputStream (File (cacheDir, File (asset).nameWithoutExtension + " _perceptual.jpg" ))
264- fosRec2408Perc.use {
265- srcPerceptual.compress(Bitmap .CompressFormat .JPEG , 90 , it)
266- it.flush()
267- }
268- // val srcImage = JxlCoder.decode(buffer4,
269- // preferredColorConfig = PreferredColorConfig.RGB_565,
270- // toneMapper = JxlToneMapper.REC2408)
271225 lifecycleScope.launch {
272226 imagesArray.add(srcImage)
273- imagesArray.add(srcPerceptual)
274227 }
275-
276228 }
277- Log .d(" JXLCoder " , " Decoding done in ${time } ms" )
229+ Log .d(" JXLMain " , " Decoding time ${decodingTime } ms" )
278230 }
279231 } catch (e: Exception ) {
280232 if (e !is FileNotFoundException ) {
@@ -289,25 +241,6 @@ class MainActivity : ComponentActivity() {
289241 modifier = Modifier .fillMaxSize(),
290242 color = MaterialTheme .colorScheme.background
291243 ) {
292- // AsyncImage(
293- // model = "https://pdfconverter1984.blob.core.windows.net/simple/wide_gamut.jxl",
294- // contentDescription = null,
295- // imageLoader = ImageLoader.Builder(this)
296- // .components {
297- // add(JxlDecoder.Factory())
298- // }
299- // .build()
300- // )
301-
302- // Image(
303- // bitmap = image.asImageBitmap(),
304- // // painter = rememberDrawablePainter(drawable = drawable),
305- // modifier = Modifier
306- // .fillMaxWidth()
307- // .fillMaxHeight(),
308- // contentScale = ContentScale.FillWidth,
309- // contentDescription = "ok"
310- // )
311244 LazyColumn (
312245 modifier = Modifier
313246 .fillMaxSize()
@@ -322,17 +255,6 @@ class MainActivity : ComponentActivity() {
322255 contentDescription = " ok"
323256 )
324257 }
325-
326- // items(drawablesArray.count(), key = {
327- // return@items UUID.randomUUID().toString()
328- // }) {
329- // Image(
330- // rememberDrawablePainter(drawable = drawablesArray[it]),
331- // modifier = Modifier.fillMaxWidth(),
332- // contentScale = ContentScale.FillWidth,
333- // contentDescription = "ok"
334- // )
335- // }
336258 }
337259 }
338260 }
0 commit comments