0

I am changing a PNG image with a transparent background to HEIC format. I want to display the modified image using Android Studio's ImageView. To use the HEIC file I used an asset folder and an ImageDecoder.

However, the transparent background of the HEIC turned black. I converted png to heic on various sites and exported it using mac preview app, but I couldn't stop the background from turning black. I would appreciate it if you solved.

here's my code:

<androidx.appcompat.widget.AppCompatImageView
    android:layout_width="287dp"
    android:layout_height="557.5dp"
    android:layout_marginStart="1.8dp"
    android:background="@android:color/transparent"
    android:id="@+id/main_character"
    android:layout_alignParentBottom="true"/>
val drawable1 = ImageDecoder.decodeDrawable(ImageDecoder.createSource(contextRepo.getValue("main").assets,"anna_character.heic"))

main_character.background = drawable1
c-an
  • 3,543
  • 5
  • 35
  • 82
taxol
  • 187
  • 1
  • 1
  • 5
  • why do you use HEIC format? – c-an Feb 05 '20 at 06:01
  • check here: https://source.android.com/devices/camera/heif OR You may try WEBP instead. – c-an Feb 05 '20 at 06:13
  • I dont' know.. i just ordered.. I heard that heic's size is smaller than png,, so used for performance. Do you have any alternatives besides heic? – taxol Feb 05 '20 at 06:22
  • You can use WEBP - https://developer.android.com/studio/write/convert-webp. This is what Google recommends. – c-an Feb 05 '20 at 06:24
  • It's best to solve that problem, but thank you for providing a good alternative. – taxol Feb 05 '20 at 06:27
  • 1
    I heard that I can use webp instead of heic. It is better than heic. Thank you very much! 감사합니다!!! – taxol Feb 05 '20 at 06:54

0 Answers0