Skip to content

Commit bc6a213

Browse files
committed
Rebuild with updates
1 parent 727c66e commit bc6a213

File tree

8 files changed

+183
-482
lines changed

8 files changed

+183
-482
lines changed

app/src/main/java/com/radzivon/bartoshyk/avif/MainActivity.kt

Lines changed: 34 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -119,72 +119,42 @@ class MainActivity : AppCompatActivity() {
119119
var allFiles = mutableListOf<String>()
120120
allFiles.addAll(allFiles2)
121121
allFiles.addAll(allFiles1)
122-
// allFiles = allFiles.take(5).toMutableList()
123-
// allFiles = allFiles.filter { it.contains("hato-wide-gamut-8bit.avif") || it.contains("wide_gamut.avif") || it.contains("IMG_0199_rr.avif") || it.contains("bt_2020_pq.avif") }.toMutableList()
124-
// allFiles = allFiles.filter { it.contains("bbb_alpha_inverted.avif") }.toMutableList()
125-
// allFiles = allFiles.filter { it.contains("federico-beccari.avif") }.toMutableList()
126-
for (file in allFiles) {
127-
try {
128-
Log.d("AVIF", "start processing $file")
129-
val buffer = this@MainActivity.assets.open(file).source().buffer()
130-
.readByteArray()
131-
132-
val size = coder.getSize(buffer)
133-
if (size != null) {
134-
val bitmap0 = coder.decodeSampled(
135-
buffer,
136-
if (size.width > 1800 || size.height > 1800) size.width / 4 else size.width,
137-
if (size.width > 1800 || size.height > 1800) size.height / 4 else size.height,
138-
PreferredColorConfig.RGBA_8888,
139-
ScaleMode.RESIZE
140-
)
141-
// val bitmap0 = coder.decode(
142-
// buffer,
143-
// )
144-
var start = System.currentTimeMillis()
145-
146-
// var bitmap0 = coder.decode(
147-
// byteArray = buffer,
148-
// preferredColorConfig = PreferredColorConfig.RGBA_F16,
149-
// )
150-
151-
Log.d("AVIFFFF", "Decode time ${System.currentTimeMillis() - start}")
152-
153-
val encode = coder.encodeHeic(bitmap0)
154-
// val roundTripped = coder.decode(encode)
155-
//
156-
//
157-
// val round = coder.decode(
158-
// byteArray = encode,
159-
// preferredColorConfig = PreferredColorConfig.RGBA_8888,
160-
// )
161-
162-
// bitmap0.setColorSpace(ColorSpace.getFromDataSpace(DataSpace.DATASPACE_BT2020_PQ)!!)
163-
164-
lifecycleScope.launch(Dispatchers.Main) {
165-
val imageView = BindingImageViewBinding.inflate(
166-
layoutInflater,
167-
binding.scrollViewContainer,
168-
false
122+
allFiles = allFiles.filter { it.contains("test_img444.avif") }.toMutableList()
123+
for (i in 0 until 5 ) {
124+
for (file in allFiles) {
125+
try {
126+
Log.d("AVIF", "start processing $file")
127+
val buffer = this@MainActivity.assets.open(file).source().buffer()
128+
.readByteArray()
129+
130+
val size = coder.getSize(buffer)
131+
if (size != null) {
132+
val bitmap0 = coder.decodeSampled(
133+
buffer,
134+
if (size.width > 1800 || size.height > 1800) size.width / 4 else size.width,
135+
if (size.width > 1800 || size.height > 1800) size.height / 4 else size.height,
136+
PreferredColorConfig.RGBA_8888,
137+
ScaleMode.RESIZE
169138
)
170-
imageView.root.setImageBitmap(bitmap0)
171-
binding.scrollViewContainer.addView(imageView.root)
139+
var start = System.currentTimeMillis()
140+
Log.d("AVIFFFF", "Decode time ${System.currentTimeMillis() - start}")
141+
142+
lifecycleScope.launch(Dispatchers.Main) {
143+
val imageView = BindingImageViewBinding.inflate(
144+
layoutInflater,
145+
binding.scrollViewContainer,
146+
false
147+
)
148+
imageView.root.setImageBitmap(bitmap0)
149+
binding.scrollViewContainer.addView(imageView.root)
150+
}
151+
}
152+
} catch (e: Exception) {
153+
Log.d("AVIF", e.toString())
154+
if (e is FileNotFoundException || e is java.io.FileNotFoundException) {
155+
} else {
156+
throw e
172157
}
173-
// lifecycleScope.launch(Dispatchers.Main) {
174-
// val imageView = BindingImageViewBinding.inflate(
175-
// layoutInflater,
176-
// binding.scrollViewContainer,
177-
// false
178-
// )
179-
// imageView.root.setImageBitmap(round)
180-
// binding.scrollViewContainer.addView(imageView.root)
181-
// }
182-
}
183-
} catch (e: Exception) {
184-
Log.d("AVIF", e.toString())
185-
if (e is FileNotFoundException || e is java.io.FileNotFoundException) {
186-
} else {
187-
throw e
188158
}
189159
}
190160
}
-119 KB
Binary file not shown.
-43.8 KB
Binary file not shown.
-38.8 KB
Binary file not shown.
-108 KB
Binary file not shown.

0 commit comments

Comments
 (0)