日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

apk中提取图标

發(fā)布時間:2024/1/1 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 apk中提取图标 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

需要引用庫:ICSharpCode.SharpZipLib.dll

圖標(biāo)路徑:

? ? //texture path
? ? string first = "res/mipmap-xxxhdpi-v4/app_icon.png";
? ? string second = "res/drawable-xxxhdpi-v4/app_icon.png";
? ? string third = "res/drawable-hdpi-v4/app_icon.png";
? ? string fourth = "res/drawable-mdpi-v4/app_icon.png";
? ? //string fifth = "res/drawable-ldpi-v4/app_icon.png";
? ? string inputPath = "E:\\apk\\Camera.apk";
? ? string outputPath = "E:\\apk\\UnZip\\";

?

圖片的輸出路徑與輸入路徑相同

public void GetIconFromAPK(string inputpath, string outputpath)
? ? {
? ? ? ? if (!File.Exists(inputpath))
? ? ? ? {
? ? ? ? ? ? Debug.LogError("Inputpath doesn't exist");
? ? ? ? }
? ? ? ? else
? ? ? ? {
? ? ? ? ? ? if (!Directory.Exists(outputpath))
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Directory.CreateDirectory(outputpath);
? ? ? ? ? ? }
? ? ? ? ? ? string fileName = Path.GetFileName(inputpath).Replace(".apk", ".png");
? ? ? ? ? ? ZipFile file = new ZipFile(inputpath);

? ? ? ? ? ? //判斷壓縮文件中是否存在該文件
? ? ? ? ? ? ZipEntry entry;
? ? ? ? ? ? entry = file.GetEntry(first);
? ? ? ? ? ? if (entry == null)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? entry = file.GetEntry(second);
? ? ? ? ? ? }
? ? ? ? ? ? if (entry == null)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? entry = file.GetEntry(third);
? ? ? ? ? ? }
? ? ? ? ? ? if (entry == null)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? entry = file.GetEntry(fourth);
? ? ? ? ? ? ? ? Debug.LogError("Didn't find icon");
? ? ? ? ? ? }

? ? ? ? ? ? if (entry != null)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? using (var s = file.GetInputStream(entry))
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? using (FileStream streamWriter = File.Create(outputpath + fileName))
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? byte[] data = new byte[2048];
? ? ? ? ? ? ? ? ? ? ? ? int size = 0;
? ? ? ? ? ? ? ? ? ? ? ? while (true)
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? size = s.Read(data, 0, data.Length);
? ? ? ? ? ? ? ? ? ? ? ? ? ? if (size > 0)
? ? ? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? streamWriter.Write(data, 0, size);
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }

?

僅限apk中圖片名為app_icon.png,manifest中可以讀取到icon的位置,尚未研究

總結(jié)

以上是生活随笔為你收集整理的apk中提取图标的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。