@@ -45,86 +45,26 @@ class MainActivity : AppCompatActivity() {
4545// assert(HeifCoder().isAvif(buffer))
4646 val size = HeifCoder ().getSize(buffer)!!
4747 assert (size != null )
48- // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
49- // val time = measureTimeMillis {
50- // // val bitmap = HeifCoder().decodeSampled(
51- // // buffer,
52- // // size.width / 2,
53- // // size.height / 2,
54- // // PreferredColorConfig.HARDWARE
55- // // )
56- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
57- val bitmap = HeifCoder ().decodeSampled(
58- buffer,
59- 350 ,
60- 600 ,
61- PreferredColorConfig .HARDWARE ,
62- ScaleMode .FIT
63- )
64- bitmap.recycle()
65- }
66- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
67- val bitmap = HeifCoder ().decodeSampled(
68- buffer,
69- 350 ,
70- 600 ,
71- PreferredColorConfig .HARDWARE ,
72- ScaleMode .FIT
73- )
74- bitmap.recycle()
75- }
76- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
77- val bitmap = HeifCoder ().decodeSampled(
78- buffer,
79- 350 ,
80- 600 ,
81- PreferredColorConfig .HARDWARE ,
82- ScaleMode .FIT
83- )
84- bitmap.recycle()
85- }
86- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
87- val bitmap = HeifCoder ().decodeSampled(
88- buffer,
89- 350 ,
90- 600 ,
91- PreferredColorConfig .HARDWARE ,
92- ScaleMode .FIT
93- )
94- bitmap.recycle()
95- }
96- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
97- val bitmap = HeifCoder ().decodeSampled(
98- buffer,
99- 350 ,
100- 600 ,
101- PreferredColorConfig .HARDWARE ,
102- ScaleMode .FIT
103- )
104- bitmap.recycle()
105- }
106- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
107- val bitmap = HeifCoder ().decodeSampled(
108- buffer,
109- 350 ,
110- 600 ,
111- PreferredColorConfig .HARDWARE ,
112- ScaleMode .FIT
113- )
114- bitmap.recycle()
115- }
116- // // val opts = BitmapFactory.Options()
117- // // opts.inMutable = true
118- // // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
119- // // opts.inPreferredConfig = Bitmap.Config.RGBA_F16
120- // // }
121- // binding.imageView.setImageBitmap(bitmap)
122- // }
123- // Log.i("MainActivity AVIF ", "Done in ${time}")
124- // // val encoded = HeifCoder().encodeAvif(bitmap)
125- // // val decodedSample = HeifCoder().decode(encoded)
126- // // binding.imageView.setImageBitmap(bitmap)
48+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU ) {
49+ val time = measureTimeMillis {
50+ val bitmap = HeifCoder ().decodeSampled(
51+ buffer,
52+ size.width / 2 ,
53+ size.height / 2 ,
54+ PreferredColorConfig .RGB_565
55+ )
56+ // val opts = BitmapFactory.Options()
57+ // opts.inMutable = true
58+ // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
59+ // opts.inPreferredConfig = Bitmap.Config.RGBA_F16
12760// }
61+ binding.imageView.setImageBitmap(bitmap)
62+ }
63+ Log .i(" MainActivity AVIF " , " Done in ${time} " )
64+ // val encoded = HeifCoder().encodeAvif(bitmap)
65+ // val decodedSample = HeifCoder().decode(encoded)
66+ // binding.imageView.setImageBitmap(bitmap)
67+ }
12868
12969 // https://wh.aimuse.online/creatives/IMUSE_03617fe2db82a584166_27/TT_a9d21ff1061d785347935fef/68f06252.avif
13070 // https://wh.aimuse.online/preset/federico-beccari.avif
@@ -135,12 +75,15 @@ class MainActivity : AppCompatActivity() {
13575// .skipMemoryCache(true)
13676// .into(binding.imageView)
13777
138- binding.imageView.load(" https://wh.aimuse.online/creatives/IMUSE_03617fe2db82a584166_27/TT_a9d21ff1061d785347935fef/68f06252.avif" ,
139- imageLoader = ImageLoader .Builder (this )
140- .components {
141- add(HeifDecoder .Factory ())
142- }
143- .build())
78+ // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
79+ // binding.imageView.load("https://wh.aimuse.online/preset/federico-beccari.avif",
80+ // imageLoader = ImageLoader.Builder(this)
81+ // .components {
82+ // add(HeifDecoder.Factory())
83+ // }
84+ // .bitmapConfig(Bitmap.Config.HARDWARE)
85+ // .build())
86+ // }
14487
14588// binding.imageView.setImageBitmap(bitmap)
14689// binding.imageView.setImageBitmap(cc16)
0 commit comments