momosolaris
V2EX  ›  问与答

Android Studio 如何加载.tif 文件格式的图像

  •  
  •   momosolaris · Sep 7, 2022 · 2031 views
    This topic created in 1521 days ago, the information mentioned may be changed or developed.
    我是个新手,我得到一个任务, 就是在 android studio 里面加载一个.tif 文件格式的图像, 然后进行一个图像转换的方法。现在我有一个问题, 我不知道比如 1.tif 的图像是加载 res/drawable 下(里面有 ic_launcher_background.xml )的还是要另外创建一个文件夹。我在 github 找到一个项目 https://github.com/Beyka/Android-TiffBitmapFactory 。 但这个我看不懂, 你们谁知道吗,我没什么头绪
    6 replies  •  2022-09-08 20:44:11 +08:00
    guchengyehai1
    guchengyehai1
    Sep 7, 2022 via iPhone
    1
    转换一下呗,转成 png 或者 webp
    xiaoliu926
    xiaoliu926
    Sep 7, 2022
    2
    res 下有好几个 drawable 文件夹,对应不同分辨率的图片,比如 drawable 、drawable-xxx 、drawable-xxxhdpi (这个文件夹可能需要自己手动创建),其实放任何一个文件夹里都是可以的,
    我个人习惯是 drawable 文件夹里放自定义的 xml 文件,drawable-xxx 里放低分率的图片,drawable-xxxhdpi 里放高分辨率的图片
    airmour
    airmour
    Sep 7, 2022
    3
    把图片放到 assets 目录里,然后使用 你发的开源项目里提供的方法转换图片格式
    TiffConverter.convertTiffJpg("file:///android_asset/1.tif", "/sdcard/out.jpg", options, progressListener);
    具体代码看项目中的 readme https://github.com/Beyka/Android-TiffBitmapFactory#converting-to-tiff
    momosolaris
    momosolaris
    OP
    Sep 8, 2022
    4
    @xiaoliu926 好的谢谢,
    momosolaris
    momosolaris
    OP
    Sep 8, 2022
    5
    @airmour 我试一下,把它放在 assets 。
    momosolaris
    momosolaris
    OP
    Sep 8, 2022
    6
    @xiaoliu926 好的,我今天试一下,谢谢你
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1687 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 16:24 · PVG 00:24 · LAX 08:24 · JFK 11:24
    ♥ Do have faith in what you're doing.