@@ -107,91 +107,12 @@ class MainActivity : ComponentActivity() {
107107 lifecycleScope.launch(Dispatchers .IO ) {
108108 val buffer5 =
109109 assets.open(" test_image_1.jpg" ).source().buffer().readByteArray()
110- val bitmap = BitmapFactory .decodeByteArray(buffer5, 0 , buffer5.size)
111- .scale(1305 , 1295 )
112- // val encoder = JxlAnimatedEncoder(
113- // bitmap.width,
114- // bitmap.height,
115- // dataPixelFormat = JxlEncodingDataPixelFormat.BINARY_16
116- // )
117- // repeat(4) {
118- // encoder.addFrame(bitmap, 24)
119- // }
120- // val encoded = encoder.encode()
121-
122- // val animated = JxlCoder.decode(encoded)
123- // lifecycleScope.launch {
124- // imagesArray.add(animated)
125- // }
126- //
127- // fun simpleRoundTrip(image: String) {
128- // val bufferPng = assets.open(image).source().buffer().readByteArray()
129- // val bitmap = BitmapFactory.decodeByteArray(bufferPng, 0, bufferPng.size)
130- // .copy(Bitmap.Config.RGBA_1010102,true)
131- // lifecycleScope.launch {
132- // imagesArray.add(bitmap)
133- // }
134- // val jxlBuffer = JxlCoder.encode(bitmap,
135- // channelsConfiguration = JxlChannelsConfiguration.RGB,
136- // compressionOption = JxlCompressionOption.LOSSY,
137- // effort = JxlEffort.LIGHTNING,
138- // decodingSpeed = JxlDecodingSpeed.SLOW)
139- // // val decodedEncoded = JxlCoder.decode(jxlBuffer,
140- // // preferredColorConfig = PreferredColorConfig.RGBA_1010102)
141- // val decodedEncoded = JxlAnimatedImage(jxlBuffer).getFrame(0, bitmap.width /2 , bitmap.height / 2)
142- // lifecycleScope.launch {
143- // imagesArray.add(decodedEncoded)
144- // }
145- // val fos = FileOutputStream(File(cacheDir, image))
146- // fos.sink().buffer().use {
147- // it.writeAll(ByteArrayInputStream(jxlBuffer).source().buffer())
148- // it.flush()
149- // }
150- // }
151- //
152- // simpleRoundTrip("screenshot_discord_5.png")
153- // simpleRoundTrip("screen_discord.png")
154- // simpleRoundTrip("screen_discord_2.png")
155- //
156- // val buffer5 = assets.open("elephant.png").source().buffer().readByteArray()
157- // val jxlBufferPNG = JxlCoder.Convenience.apng2JXL(buffer5, quality = 55)
158- // val buffer = assets.open("abstract_alpha.png").source().buffer().readByteArray()
159- // val bitmap = BitmapFactory.decodeByteArray(buffer, 0, buffer.size)
160- // .copy(Bitmap.Config.ARGB_8888, true)
161- // lifecycleScope.launch {
162- // drawables.add(BitmapDrawable(resources, bitmap))
163- // }
164- // val space = bitmap.copy(Bitmap.Config.ARGB_8888, true)
165- // val encoded =
166- // JxlCoder.encode(
167- // space,
168- // channelsConfiguration = JxlChannelsConfiguration.RGB,
169- // effort = JxlEffort.LIGHTNING,
170- // compressionOption = JxlCompressionOption.LOSSLESS,
171- // quality = 100,
172- // )
173- // val decoded = JxlCoder.decodeSampled(
174- // encoded,
175- // preferredColorConfig = PreferredColorConfig.HARDWARE, width = 1305,
176- // height = 1295
177- // )
178- // lifecycleScope.launch {
179- // imagesArray.add(decoded)
180- // }
181-
182- val display: Display = this @MainActivity.windowManager.defaultDisplay
183- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ) {
184- val hdrCapabilities = display.hdrCapabilities
185- val maxNits = hdrCapabilities.desiredMaxLuminance
186- val whitePoint = hdrCapabilities.desiredMaxAverageLuminance
187- Log .d(" Max HDR value" , " $maxNits whitePoint $whitePoint " )
188- }
189110
190111 var assets =
191112 (this @MainActivity.assets.list(" " ) ? : return @launch).toList()
192113// assets = assets.filter { it.contains("20181110_213419__MMC1561-HDR.jxl") }
193114// assets = assets.take(15)
194- // assets = assets.filter { it.contains("test_f32_image .jxl") }
115+ // assets = assets.filter { it.contains("test_img_q80 .jxl") }
195116 for (asset in assets) {
196117 try {
197118 val buffer4 =
@@ -201,13 +122,6 @@ class MainActivity : ComponentActivity() {
201122 val largeImageSize = JxlCoder .getSize(buffer4)
202123 if (largeImageSize != null ) {
203124 val decodingTime = measureTimeMillis {
204- // val srcImage = JxlCoder.decode(
205- // buffer4,
206- // preferredColorConfig = PreferredColorConfig.HARDWARE,
207- // com.awxkee.jxlcoder.ScaleMode.FIT,
208- // toneMapper = JxlToneMapper.REC2408,
209- // )
210-
211125 // Resizable version
212126 val srcImage = JxlCoder .decodeSampled(
213127 buffer4,
0 commit comments