突发奇想我想把Dota2客户端里的英雄、道具、技能等图标都从客户端里扒出来再做一个Dota2图标的马赛克拼图。这里就分为两个任务:1、从客户端扒icon;2、做马赛克拼图。
首先针对如何从客户端扒icon的问题搜了下相关资料,发现有相关教程提及,在dota2安装路径中找到SteamLibrarysteamappscommondota 2 betagamedota,使用工具
GCFScape - Valve Developer Communitydeveloper.valvesoftware.com![2fd1550eae26552229c66a5d88e06be2.png](https://i-blog.csdnimg.cn/blog_migrate/6f8a8a491f1ff61693f1d47c7030d3f6.png)
对该路径下的pak01_dir.vpk进行解压,可以得到如下图的文件结构。
![705559a94277021b691198e0ee90403b.png](https://i-blog.csdnimg.cn/blog_migrate/a9336502daf4ff2cb0c6da2b646e5912.jpeg)
找到的教程中提及在root/resource/flash3/images下存在多个文件夹保存有英雄、道具等图标,但在最新版本(2020.3.25)客户端中仅存在hud_skin文件夹,内部包含多种界面相关图层,并无英雄、道具icon。
经寻找,在root/panaroma/images/下找到了如下三个文件夹:
heros/icons; items; spellicons。
从名字可以判定是英雄、道具、技能的图标。但内部包含的文件均为.vetx_c文件,经查,这是v社进行编译后的文件,在github上搜索,找到了
ValveResourceFormatgithub.com可以进行v社编译文件的反编译,预编译的文件可以在这个链接下载
AppVeyorci.appveyor.com包含三个文件:
![e361a9e3c5d506f7fd21a3f96034c79b.png](https://i-blog.csdnimg.cn/blog_migrate/5aed009644029bd90f1171d7ece33d3b.png)
Decompiler是一个cli反编译工具,也是最核心工具,nupkg是一些配置文件,把另外两个文件放在GUI同一目录下可以用图形化界面操作反编译。但是GUI工具一次只能反编译一个文件,而且反编译的输出需要手动保存,考虑到我需要反编译非常多的文件,所以我选择用python调用Decompiler.exe进行批量输出。详细代码如下:
import os
hero_path = r'D:Dota2资源解压rootpanoramaimagesheroesicons'
item_path = r'D:Dota2资源解压rootpanoramaimagesitems'
spell_path = r'D:Dota2资源解压rootpanoramaimagesspellicons'
def decompile(input_file, output_file):
os.system(r'C:UsersyuhwachoongDesktopGUIDecompiler.exe'
r' -i {input_file}'
r' -o {output_file}'
.format(input_file=input_file, output_file=output_file))
def decompile_all(path, output_path):
for root, dirs, files in os.walk(path):
for file in files:
print(file)
this_file = os.path.join(root, file)
this_output_file = os.path.join(output_path, file + '.png')
decompile(this_file, this_output_file)
decompile_all(hero_path, r'iconsheros')
decompile_all(item_path, r'iconsitems')
decompile_all(spell_path, r'iconsspell')
把代码中相应的Decompiler和解压完的文件路径进行相应修改即可。可以得到如下图的一系列图标,共计有1537个图标。
![4a61a2814c3e499a5602872f09603276.png](https://i-blog.csdnimg.cn/blog_migrate/86af771e9c5a72469fff1b1978d53a09.jpeg)
![c77307ffe95fd3152379ae4a33c478a7.png](https://i-blog.csdnimg.cn/blog_migrate/fefaf0ef7df7425bebd6c58e8f815b37.jpeg)
![fe4ee3426592e92d7377236a7d702f34.png](https://i-blog.csdnimg.cn/blog_migrate/2af8d291474f492c03f5dd9b0570dd43.jpeg)
至此就把英雄、技能、道具的icon都扒出来了,接下来需要生成Dota2图标的马赛克拼图。
首先找一张Dota2的logo图:
![1d6a65d4375300b30e1807cf3b25eef4.png](https://i-blog.csdnimg.cn/blog_migrate/cab0e52ace6bbb0e1cfda85f8eb3891b.jpeg)
然后我又先再github上找了一轮制作马赛克拼图的python程序,大多是用建立图片索引-样本图像分割-rgb匹配的方式制作的,最终效果不太理想,可能长这个样子:
![120aec3d2158ece8ab3bc1b9b1d7a3ff.png](https://i-blog.csdnimg.cn/blog_migrate/2f16347cadc9e70d085c686a8638a19a.jpeg)
过于一言难尽。。。所以还是使用了比较成熟的马赛克拼图软件
Welcome | FMEdda | Foto-Mosaik-Eddafmedda.com![cb6c0caabdb306e349eb81ae49d59557.png](https://i-blog.csdnimg.cn/blog_migrate/7f133d5e5404e3de51e7e8d03d98df7a.jpeg)
制作,只需要把icons加入database,然后点击Create photo masaic选择样本图片和输出路径就可以了,样图如下:
![3699f43665bcc44ec56008c41fbf56f3.png](https://i-blog.csdnimg.cn/blog_migrate/a61ab179835e5c112afae9432eb0d8a0.jpeg)
可以看出该软件其实是用Database的icons做了拼接以后再把马赛克化的样本图片叠加上去的,虽然视觉效果更好,但是与最初的设想(纯粹的rbg匹配拼合)有一点点不一样。注意在制作马赛克照片的时候尽量合适一点的tile,可以保证马赛克图的精细度不会太糟糕。